从Internet Explorer中的网页通过vba进行网页抓取问题

时间:2018-04-23 09:38:27

标签: vba web-scraping web-crawler

我想创建一个抓取工具,从网站上删除城市名称及其各自的餐馆数量,但我收到错误,无法理解获取类名和标签名称的过程。请帮助我获取相关信息HTML的元素,以便获取所需的详细信息。

Dim ieobj As InternetExplorer
Dim iedoc As Object
Dim tag As Object
Dim str As String

Public Sub scrape()

Set ieobj = CreateObject("internetexplorer.application")
    With ieobj
    .navigate ("**********")
    .Visible = True
    strtimer = Now() + TimeValue("00:00:05")

    Do Until .readystate = 4
    If TimeValue(Now()) > TimeValue(strtimer) Then
    End If
Loop
End With

Application.Wait (Now() + TimeValue("00:00:05"))

Set iedoc = ieobj.document

Set div_result = iedoc.getElementsByClassName("")(0)
    Set header_links = div_result.getElementsByTagName("a")(0).innerText
    Set header_links1 = div_result.getElementsByTagName("a")(0).Hyperlink
    For Each h In header_links
        Set link = h.ChildNodes.Item(0)
        Cells(Range("A" & Rows.Count).End(xlUp).Row + 1, 12) = h.href
    Next

End Sub

0 个答案:

没有答案