help Convert code from XMLhttp to WINhttp


New Member
Feb 11, 2017
I have made a scraper using vba xmhttp method which is parsing 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 = ""
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

= 2

For u = 2 To 6

.Open "GET", pageurl & u, False
.body.innerHTML = http.responseText

Set posts = html.getElementsByClassName("row businessCapsule--title")

For Each post In posts
Set links = post.getElementsByTagName("a")(0)
(x, 1) = links.innerText
= x + 1
Next post
Next u
End Sub</code>

Forum statistics

Latest member

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...