shahin
Active Member
Dear all, hope you are doing fine. I have made a scraper using vba xmhttp method which is parsing yell.com very smoothly at this moment. But i noticed that the site sometimes uses redirection method, as a result i end up with nothing when i run the code. So if there somebody out here help me creating this same code using winhttp method then i would really be indebted to him. I never worked with this method so far that is why it is totally foreign to me. For your consideration i am pasting here the code i have written. Thanks a trillion in advance.
Code:
Option Explicit
Const pageurl As String = "https://www.yell.com/ucs/UcsSearchAction.do?keywords=cafes+%26+coffee+shops&location=all+states&scrambleSeed=1864223494&pageNum="
Sub ScrapingYell()
Dim http As New MSXML2.XMLHTTP60
Dim html As New HTMLDocument
Dim posts As Object, post As Object, links As Object, link As Object
Dim x As Long, u As Long
x = 2
For u = 2 To 6
http.Open "GET", pageurl & u, False
http.send
html.body.innerHTML = http.responseText
Set posts = html.getElementsByClassName("row businessCapsule--title")
For Each post In posts
Set links = post.getElementsByTagName("a")(0)
Cells(x, 1) = links.innerText
x = x + 1
Next post
Next u
End Sub