I need to save data from thousands of different web pages. . Most of them work with this code:
Option Explicit
Function SaveWebFile(ByVal vWebFile As String, ByVal vLocalFile As String) As Boolean
Dim oXMLHTTP As Object, i As Long, vFF As Long, oResp() As Byte
Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP")
oXMLHTTP.Open "GET", vWebFile, False
oXMLHTTP.send
Do While oXMLHTTP.readyState <> 4
DoEvents
Loop
oResp = oXMLHTTP.responseBody
vFF = FreeFile
If Dir(vLocalFile) <> "" Then Kill vLocalFile
Open vLocalFile For Binary As #vFF
Put #vFF, , oResp
Close #vFF
Set oXMLHTTP = Nothing
End Function
Sub meh()
SaveWebFile "https://apps.dep.wv.gov/oog/wellsearch_new.cfm", _
"C:\User\Desktop\blahBlahxls"
End sub
But several websites (similar to the one above) require some sort of criteria or parameters submitted before updating..
I can get around this with VBA code used to navigate and return innerText, but its very slow when having to run it hundreds of times. My problem here is that I cant figure out how to send a request with my parameters included.
For example: With the website above, I want to use the operator name "pine mountain" and i want to check the box at the bottom "Check here for MS Excel format". I have tried setcredentials("OperatorName,"Pine mountain") and also .setRequestheader. . Any help or advice would be greatly appreciated.
Bookmarks