2015-10-19 31 views
-1

我是VBA的新手,因此不勝感激。如何從源代碼與VBA抓取鏈接

我想收集所有的搜索結果鏈接的從源代碼中此網站:

http://ingatlan.com/lista/elado+telek+budaors

它是源爲: HREF =「/布達厄爾什/ elado + telek/egyeb-telek /害蟲+ megye +布達厄爾什+ sovirag + utca街+ 8-10/21503632

但是它不會鏈接到任何表

感謝: 阿提拉

+2

請告訴我們你試圖完成你的任務,那麼我們就可以幫助調整你的代碼來得到它的工作,如果它不能正常工作......這就是說,有幾頁是什麼這個鏈接,應該可以幫助你:http://www.jpsoftwaretech.com/excel-vba/automate-internet-explorer/ –

+0

也許這個答案會幫助你... http://stackoverflow.com/questions/7393236/reading -web-pages-using-excel-vba/7413486#7413486 – MikeD

+0

提示:你想用class =「search-results」來查看table元素的子元素, – MikeD

回答

0

我有以下腳本從一個特定的鏈接下載數據:

子Adott_hirdetes_adatai()

Dim IE As Object: Set IE = CreateObject("InternetExplorer.Application") 
    IE.Visible = False 

    Application.ScreenUpdating = False 
    Application.DisplayAlerts = False 

    For X = 1 To 1 
    Application.StatusBar = X 

    IE.Navigate "http://ingatlan.com/budaors-torokugrato/elado+telek  /lakoovezeti-telek/pest+megye+budaors/21284950" 

    Do Until Not IE.Busy And IE.ReadyState = 4 
     Application.Wait (Now + #12:00:01 AM#) 
    Loop 

    'Hirdetés azonosítója 
    BazsiSheet.Cells(X, 1) = "Hirdetés azonosítója" 
    BazsiSheet.Cells(X + 1, 1) = IE.Document.getElementsByClassName("adid")(0).innertext 
    'Hirdetés fejléce 
     BazsiSheet.Cells(X, 2) = "Hirdetés neve" 
     BazsiSheet.Cells(X + 1, 2) = IE.Document.getElementsByClassName("pageTitle")(0).innertext 

「雙人牀價格 BazsiSheet.Cells(X,3)= 「AR」 BazsiSheet。 (0).getElementsByTagName(「td」)(0).innertextxt (X + 1,3)= IE.Document.getElementsByClassName(「importantInformations four-column 'Terület BazsiSheet.Cells(X,4)=「Terület」 BazsiSheet.Cells(X + 1,4)= IE.Document.getElementsByCla ssName(「importantInformations four-column-table」)(0).getElementsByTagName(「tr」)(0).getElementsByTagName(「td」)(1).innertextxt 'A「Típus」szókiíratása BazsiSheet.Cells(X (0).getElementsByTagName(「td」)(0)。,5)=「Típus」 (X,1,6)= IE.Document.getElementById(「table」)。getElementsByTagName(「tr」)是一個非常有用的字符串表達式。 )(0).getElementsByTagName(「td」)(1).innertextxt 'A「villany」szókiíratása BazsiSheet.Cells(X,7)=「Villany」 BazsiSheet.Cells(X + 1,7)= IE .Document.getElementById( 「表」)。的getElementsByTagName( 「TR」)(1).getElementsByTag Name(「td」)(0).innertextxt 'A「Csatorna」szókiíratása BazsiSheet.Cells(X,8)=「Csatorna」 BazsiSheet.Cells(X + 1,8)= IE.Document.getElementById 「table」)。getElementsByTagName(「tr」)(1).getElementsByTagName(「td」)(1).innertextxt 'A「viz」szókiíratása BazsiSheet.Cells(X,9)=「Víz」 BazsiSheet。單元格(X + 1,9)= IE.Document.getElementById(「table」)。getElementsByTagName(「tr」)(2).getElementsByTagName(「td」)(0).Innertextxt 'A「killers」szókiíratása BazsiSheet.Cells(X,10)=「Kilátás」 BazsiSheet.Cells(X + 1,10)= IE.Document.getElementById(「table」)。getElementsByTagName(「tr」)(2).getElementsByTagName(「td」 )(1).nenertextxt 'Ahirdetésszövege BazsiSheet.Cells(X,11)= 「Komment」 BazsiSheet.Cells(X + 1,11)= IE.Document.getElementsByClassName( 「箱形截面評論」)(0).innertext

 Next X 

     Set IE = Nothing 

     Application.StatusBar = "" 
     Application.ScreenUpdating = True 
     Application.DisplayAlerts = True 

     End Sub 

哪些工作正常,但我仍然無法收集搜索結果中的鏈接。

感謝: 阿提拉