Hi guys,
I'm trying to automate through vba a script that will follow a list of hyperlinks to Google search results and to copy the phone number listed for each link (phone numbers in google searches are listed on the right hand side).
Example link showing the phone number on the right hand side for Best Buy is below in the code.
I am unable to figure out how to reference the open browser and webscrape for the phone number to paste into a specific cell. Any help would be appreciated.
Thanks!
Some of the code:
I'm trying to automate through vba a script that will follow a list of hyperlinks to Google search results and to copy the phone number listed for each link (phone numbers in google searches are listed on the right hand side).
Example link showing the phone number on the right hand side for Best Buy is below in the code.
I am unable to figure out how to reference the open browser and webscrape for the phone number to paste into a specific cell. Any help would be appreciated.
Thanks!
Some of the code:
HTML:
Sub data()
Dim i As Integer
i = 2
ActiveWorkbook.FollowHyperlink Address:="https://www.google.ca/search?rlz=1C1GCEA_enCA793CA793&ei=tXMBXPmPLYXljwSx_qyABQ&q=bestbuy&oq=bestbuy&gs_l=psy-ab.3..0i131i67j0i131l2j0i67l2j0i10j0i67j0j0i67l2.14142.14860..15021...0.0..0.94.544.7......0....1..gws-wiz.......0i71.JDd44WmjBlY"
With CreateObject("Shell.Application").Windows
Set IE = .Item(0) ' or .Item(.Count - 1)
End With
IE.Document.getElementsByClassName("Z1hOCe").Copy
ActiveSheet.Paste Destination:=Worksheets("Sheet1").Range("a1")
End Sub