VLearnVibium

How to Automate a Google Search with Vibium

Automate a Google search with Vibium in Python — open Google, type a query, submit it, and read the result titles in about ten lines of code.

By Pramod Dutta··3 min read·Verified with Vibium 26.2
▶ Animated overview · made with Remotion

To automate a Google search with Vibium, launch the browser, go() to google.com, find() the search box, type() your query, submit it, then read the result titles with findAll(). Vibium auto-waits for each element to be actionable, so you do not write a single sleep(). Because Vibium is a single Go binary that downloads its own copy of Chrome for Testing, there is no driver to install and no version-matching headache — pip install vibium and the script below runs. The whole flow is about a dozen lines: open the page, type into the input named q, press Enter, and Vibium waits for the results page to render before you scrape the headings. This same pattern works on any site with a search field, which makes it a great first real-world automation to learn.

What is the Google search script?

from vibium import browser_sync as browser
 
vibe = browser.launch()
vibe.go("https://www.google.com")
 
box = vibe.find('textarea[name="q"]')
box.type("vibium browser automation")
box.press("Enter")
 
results = vibe.findAll("h3")
for r in results[:10]:
    print(r.text())
 
vibe.quit()

Run it and you get the top result headings printed to your terminal. Vibium opens Chrome, types into Google's search box, presses Enter, waits for the results to render, then reads every <h3> — which is how Google marks result titles.

How does each step work?

  1. browser.launch() — starts Chrome over WebDriver BiDi and returns a vibe object you drive the page with.
  2. vibe.go(url) — navigates to Google and returns once the load event fires.
  3. vibe.find('textarea[name="q"]') — locates the search box. Google renders its main search field as a <textarea> with name="q". Vibium auto-waits until it is actionable before you type.
  4. box.type("...") — enters the query character by character, like a real user.
  5. box.press("Enter") — sends a real Enter key event to submit the search.
  6. vibe.findAll("h3") — returns a list of every result-title element on the page.

Because find() waits for actionability automatically, you never race Google's render. Read more about that in waiting and actionability.

In many regions Google shows a consent dialog before the search box is usable. Click the accept button first, then continue — Vibium's semantic locators let you target it by its accessible role and text rather than a brittle CSS path:

from vibium import browser_sync as browser
 
vibe = browser.launch()
vibe.go("https://www.google.com")
 
# Dismiss the consent banner if it appears
vibe.find(role="button", text="Accept all").click()
 
box = vibe.find('textarea[name="q"]')
box.type("playwright alternative")
box.press("Enter")
 
print(vibe.find("h3").text())  # first result title
 
vibe.quit()

If no banner shows, that first find() will time out — wrap it in a try/except if your script must run in regions both with and without the dialog.

Each result title sits inside an anchor, so read the parent link's href while you are looping. Scope a find() to each result block to keep titles and URLs paired:

blocks = vibe.findAll("div.g, div[data-hveid]")
for block in blocks[:10]:
    try:
        title = block.find("h3").text()
        link = block.find("a").get_attribute("href")
        print(title, "->", link)
    except Exception:
        continue

Google's result markup changes often, so treat the selectors above as a starting point and inspect the live page if a class stops matching.

Why use Vibium for this instead of requests?

A plain HTTP request to Google returns markup that JavaScript has not yet rendered, and Google actively varies its response for non-browser clients. Vibium drives a real Chrome, so you get the page a human would see — rendered results, lazy-loaded content, and all. The trade-off is that automated consumer-search queries can trigger CAPTCHAs; for production-grade data, switch to Google's official Custom Search JSON API and keep this Vibium pattern for sites that lack an API.

Next steps

Frequently asked questions

How do I automate a Google search with Vibium?

Launch the browser, go() to google.com, find the search box by its name attribute, type() your query, press Enter or click search, then read the result titles with findAll() and text(). Vibium auto-waits for each element, so no manual sleeps are required.

How does Vibium submit a search query?

After typing into the search field you can submit with element.press('Enter'), which sends a real key event, or by clicking the search button. Vibium then auto-waits for the results page, so you read result links straight after without timing the navigation yourself.

Is automating Google search against the rules?

Google's terms discourage automated querying of its consumer search page, and heavy use can trigger CAPTCHAs. For learning, light scripting is fine; for production data, use the official Custom Search JSON API. The same Vibium pattern works on any site with a search box.

Vibium is created by Jason Huggins. This is an independent tutorial — see the official Vibium site and GitHub repo for canonical docs.

Related guides