Scraper已停止工作,可能是一个小问题但无法找到问题

时间:2015-07-03 08:56:00

标签: vba scraper

此刮刀应返回建议在搜索中显示多少属性的数据。

它一直工作,直到我今天早上打开它,课程没有改变,但由于某种原因,它不会将任何数据返回到所述的单元格中。

Sub ZPLA2()

  Const READYSTATE_COMPLETE = 4

    Dim j As Integer

    Dim ie As InternetExplorer
    Dim Doc As IHTMLDocument
    Dim xcolElements As IHTMLElementCollection
    Dim ell As IHTMLElement

    Dim pn As Integer
    Set ie = CreateObject("InternetExplorer.Application")

    ie.Visible = True
    ie.Navigate "http://www.zoopla.co.uk/for-sale/property/london/w1/west-end-mayfair-soho-marylebone-south/?beds_max=0&beds_min=0&include_retirement_homes=true&include_shared_ownership=true&new_homes=include&price_max=200000&price_min=50000&q=w1&radius=20&results_sort=newest_listings&search_source=refine"
    ' Do
    'DoEvents
    'Loop Until Not ie.Busy And ie.readyState = READYSTATE_COMPLETE
    Application.Wait (Now + TimeValue("0:00:07"))
    Set Doc = ie.Document

    Set xcolElements = Doc.getElementsByClassName("split3l result-count")

    For Each ell In xcolElements

      Sheet2.Range("d2").Value = ell.innerText
      On Error GoTo skip

    Next

skip:
    ie.Quit
    Set el = Nothing
    Set xcolElements = Nothing
    Set Doc = Nothing
    Set ie = Nothing
End Sub

1 个答案:

答案 0 :(得分:1)

替换

 Set xcolElements = Doc.getElementsByClassName("split3l result-count")

使用:

Set xcolElements = Doc.getElementsByClassName("listing-results-utils-count")

请记住使用IE开发者工具而不是Chrome等,因为您实际上是在上面的代码中使用VBA中的IE浏览器。