I'm using MS Access 2010 to make web scrape at Google page.
My scenario
- Table1 with column A with some words to search and column B to store the number of results, C the day I made the query and D the time.
- An execute search Macro
- Column A can be changed so I need to do the search only when I press the check button
My doubts:
- I've been reading about XMLHttpRequest but finally, I don't get if for a "small" search is better to use "GET" or "POST" method
- I can change the Google home page but I can't change search term and make the query by click the button. I only receive as responseText the original HTML text from URL base (www.google.com)
The code I have so far:
Option Compare Database
Sub test()
Dim XMLPage As New MSXML2.XMLHTTP60
Dim rs As DAO.Recordset
Dim search As Object
' Create the recordset with all the values we have at Column A At Table1
Set rs = CurrentDb.OpenRecordset("SELECT * From Table1")
'Establish the URL from I want to scrape
myUrl = "www.google.es"
Do Until rs.EOF
XMLPage.Open "GET", myUrl, False
XMLPage.setRequestHeader "Content-Type", "application/x-222-form-urlencoded"
' With XMLPage
Set search = rs("WordSearch")
XMLPage.Document.getElementsByClassName("iblpc") = rs!WordSearch
'End With
request.send
HTMLDoc = XMLPage.responseText
Debug.Print HTMLDoc
Loop
Set XMLPage = Nothing
End Sub
I don't achieve to put the words I have at Wordsearch column and click on the search button and store the values indicated into the other columns. Any help will be very helpful