Guest User

Untitled

a guest
Oct 30th, 2020
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1.  
  2. Option Explicit
  3.  
  4. Sub GetZillowSold()
  5.  
  6. Dim XMLReq As New MSXML2.XMLHTTP60
  7. Dim HTMLDoc As New MSHTML.HTMLDocument
  8.  
  9. Dim ListCards As MSHTML.IHTMLElementCollection
  10. Dim InfoCard As MSHTML.IHTMLElement
  11.  
  12. Dim SoldList As MSHTML.IHTMLElementCollection
  13. Dim SoldDate As MSHTML.IHTMLElement
  14.  
  15. Dim Zpages As MSHTML.IHTMLElementCollection
  16. Dim Zpage As MSHTML.IHTMLElement
  17.  
  18. Dim CardID As Integer
  19.  
  20. XMLReq.Open "GET", "https://www.zillow.com/the-colony-tx/sold/house_type/3-_beds/", False
  21. XMLReq.send
  22.  
  23. If XMLReq.Status <> 200 Then
  24. MsgBox "Problem" & vbNewLine & XMLReq.Status & " - " & XMLReq.statusText
  25. Exit Sub
  26. End If
  27.  
  28. Worksheets.Add
  29. Range("A1").Value = "Address"
  30. Range("b1").Value = "Price"
  31. Range("c1").Value = "Bedroom"
  32. Range("d1").Value = "Bath"
  33. Range("e1").Value = "Sqft"
  34. Range("f1").Value = "Date"
  35. Range("A2").Select
  36.  
  37. HTMLDoc.body.innerhtml = XMLReq.responseText
  38. Set XMLReq = Nothing
  39.  
  40.  
  41.  
  42. Set ListCards = HTMLDoc.getElementsByClassName("list-card-info")
  43.  
  44. 'Debug.Print ListCards.Length
  45.  
  46. For Each InfoCard In ListCards
  47. ActiveCell.Value = InfoCard.innerText
  48. ActiveCell.Offset(1, 0).Select
  49.  
  50. Next InfoCard
  51.  
  52. Range("f2").Select
  53. Set SoldList = HTMLDoc.getElementsByClassName("list-card-top")
  54. 'Debug.Print SoldList.Length,
  55.  
  56. For Each SoldDate In SoldList
  57. ActiveCell.Value = Mid(SoldDate.innerText, 6)
  58. ActiveCell.Offset(1, 0).Select
  59. Next SoldDate
  60.  
  61. Set Zpages = HTMLDoc.getElementsByTagName("a")
  62.  
  63. For Each Zpage In Zpages
  64. If (Zpage.getAttribute("title") = "Next page") Then
  65. Zpage.Click
  66. End If
  67. Exit For
  68. Next Zpage
  69. End Sub
  70.  
Add Comment
Please, Sign In to add comment