How to get Google's Search Suggestions using vba XmlHttpRequest?

amo

Board Regular
Joined
Apr 14, 2020
Messages
141
Office Version
  1. 2010
Platform
  1. Windows
i want to get data from google suggestion
how to get the data taken can be neatly arranged and repeated based on the data taken

example: first keyword: "study"
Successfully retrieved keywords:

Study Island
Study
Study Stream
Study Table

second keyword: "Study Island" etc

my code
VBA Code:
Sub tes()

Dim sData As Worksheet: Set sData = Sheets("Sheet1")
Set ch = New Selenium.ChromeDriver


On Error Resume Next

With ch
.AddArgument "--start-maximized"
.Start
.SwitchToNextWindow
.Get "https://www.google.com/"
Application.Wait (Now + TimeValue("0:00:03"))
End With

ch.FindElementByName("q").SendKeys "Study"
Application.Wait (Now + TimeValue("0:00:05"))

Sheets("Sheet1").Range("C1") = ch.FindElementByClass("aajZCb").Text

End Sub

I hope the code can be converted with XmlHttpRequest to make it faster
 

Attachments

  • Screenshot_1.png
    Screenshot_1.png
    15.9 KB · Views: 23
  • Screenshot_2.png
    Screenshot_2.png
    4.4 KB · Views: 16

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top