Hello,
I am trying to scrape data from a web query using VBA. The problem I have run into is that I can't find a way to copy the data I actually want. I have tried everything I could find on the forums (document.body document.innertext, document.outerHTML, etc.), but nothing is capturing the data I'm after. Below is my code as well as a screenshot of the data I would like to copy. I only want the first result in the query, but I am happy with pulling extraneous information (the whole page and all the results if necessary) as long as the data I want is included. I have tried to read through the HTML to find the location, but at this point I think it will take someone more talented with reading HTML than me.
[/URL][/IMG]
I am trying to scrape data from a web query using VBA. The problem I have run into is that I can't find a way to copy the data I actually want. I have tried everything I could find on the forums (document.body document.innertext, document.outerHTML, etc.), but nothing is capturing the data I'm after. Below is my code as well as a screenshot of the data I would like to copy. I only want the first result in the query, but I am happy with pulling extraneous information (the whole page and all the results if necessary) as long as the data I want is included. I have tried to read through the HTML to find the location, but at this point I think it will take someone more talented with reading HTML than me.
Code:
Sub QueryScrape()
'Dimensions IE
Dim IE As Object
'Starts loop
Set IE = CreateObject("InternetExplorer.Application")
For i = 2 To 500
strLink = "http://209.183.255.146/arcgis/rest/services/Solar/Buildings/MapServer/find?searchText=" & i - 1 & "&contains=false&searchFields=&sr=&layers=0&layerDefs=&returnGeometry=true&maxAllowableOffset=&geometryPrecision=&dynamicLayers=&returnZ=true&returnM=true&gdbVersion=&f=html"
'Opens IE
With IE
.Visible = True
.Navigate strLink
Do While IE.ReadyState <> 4
DoEvents
Loop
'Moves data to worksheet
'Range ("A" & i) = WHERE I NEED A WAY TO REFERENCE THE DATA
'Closes IE
IE.Quit
End With
'Separates data into columns
'This is code I will write to separate the data from column A into columns A through L
Next i
End Sub