shahin
Active Member
Hi there all! I have tried to make a crawler which is at this moment crawling a webpage recursively. However, I have got two problems with this.
1. Scraped data are getting overwritten in a single row but i cant make it go down as normal loop does.
2. Is there any way to set the depth of this crawler so that i can avoid infinite crawling?
Here is what I'm up to:
1. Scraped data are getting overwritten in a single row but i cant make it go down as normal loop does.
2. Is there any way to set the depth of this crawler so that i can avoid infinite crawling?
Here is what I'm up to:
Code:
Sub Candy_Crush(Z As String)
Dim http As New MSXML2.XMLHTTP60, html As New HTMLDocument
Dim Items As Object, Item As Object, Newitem As Object
Dim elem As Object, athing As Object, bthing As Object
With http
.Open "GET", Z, False
.send
html.body.innerHTML = .responseText
End With
Set Newitem = html.getElementsByClassName("name")
Set Items = html.getElementsByClassName("left")
For Each Item In Items
Set athing = Item.getElementsByTagName("h1")
Set bthing = Item.getElementsByTagName("h2")
x = x + 1
If athing.Length Then Cells(x, 2) = athing(0).innerText
If bthing.Length Then Cells(x, 3) = bthing(0).innerText
Next Item
For Each elem In Newitem
x = x + 1
Cells(x, 1) = elem.href
Candy_Crush (elem.href)
Next elem
End Sub
Sub RecursiveCrawler()
Candy_Crush ("https://itunes.apple.com/us/app/toy-blast/id890378044?mt=8")
End Sub