jmutsche
08-22-2014, 09:04 AM
Hello Experts,
I hope you are intrigued by this. I have recently taken a great interest in data scraping, and am hoping to get some help.
Website http://www.naco.org/counties/pages/citysearch.aspx?zip=84108
piece of source code I believe is needed:
<form action="zip_res.cfm" method="GET">
<input type="text" name="zip" size="7" maxlength="5">
<input type="Submit" value="Search for County">
</form>
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = Range("zipcode").Row And Target.Column = Range("zipcode").Column Then
Dim ie As New InternetExplorer
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
'ie.navigate "http://quickfacts.census.gov/cgi-bin/qfd/lookup?place=" & Range("zipcode").Value
ie.navigate "http://www.naco.org/counties/pages/citysearch.aspx?zip=" & Range("zipcode").Value
Do
DoEvents
Dim doc As HTMLDocument
myzip = Range("zipcode").Value
Loop Until ie.readyState = READYSTATE_COMPLETE
zip.Value = myzip
ie.document.getElementsByName("zip").Item.Click
sdd = doc.getElementsByTagName("tbody")(2).innerText
lr = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
Cells(lr + 1, 1) = sdd
End If
End Sub
I am struggling to fill in the form and click the submit button on the webpage. From there I think I can figure out how to loop through the results to get what I want. Can anyone help me. I have tried everything I can think of. I am just doing this for fun, but I need to understand what I am missing. I have tried all different variety's of getelements and nothing is working. I am a bit of a novice to html.
Thanks,
I hope you are intrigued by this. I have recently taken a great interest in data scraping, and am hoping to get some help.
Website http://www.naco.org/counties/pages/citysearch.aspx?zip=84108
piece of source code I believe is needed:
<form action="zip_res.cfm" method="GET">
<input type="text" name="zip" size="7" maxlength="5">
<input type="Submit" value="Search for County">
</form>
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = Range("zipcode").Row And Target.Column = Range("zipcode").Column Then
Dim ie As New InternetExplorer
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
'ie.navigate "http://quickfacts.census.gov/cgi-bin/qfd/lookup?place=" & Range("zipcode").Value
ie.navigate "http://www.naco.org/counties/pages/citysearch.aspx?zip=" & Range("zipcode").Value
Do
DoEvents
Dim doc As HTMLDocument
myzip = Range("zipcode").Value
Loop Until ie.readyState = READYSTATE_COMPLETE
zip.Value = myzip
ie.document.getElementsByName("zip").Item.Click
sdd = doc.getElementsByTagName("tbody")(2).innerText
lr = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
Cells(lr + 1, 1) = sdd
End If
End Sub
I am struggling to fill in the form and click the submit button on the webpage. From there I think I can figure out how to loop through the results to get what I want. Can anyone help me. I have tried everything I can think of. I am just doing this for fun, but I need to understand what I am missing. I have tried all different variety's of getelements and nothing is working. I am a bit of a novice to html.
Thanks,