help Convert code from XMLhttp to WINhttp

shahin2137

New Member
Joined
Feb 11, 2017
Messages
1
I have made a scraper using vba xmhttp method which is parsing yell.com very smoothly at this moment.However, I noticed that the site sometimes uses a redirection method.As a result I end up with nothing returned when I run the code.So if there is somebody out here that can help me create this same code using winhttp method I would really appreciate it.I have never worked with this method before and that is why it is totally foreign to me.For your consideration I am pasting the code I have written.

<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; white-space: inherit;">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</code>
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Forum statistics

Threads
1,214,980
Messages
6,122,563
Members
449,088
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top