DEV Community

Cover image for Realtime Google Search
Ranjan Dailata
Ranjan Dailata

Posted on

Realtime Google Search


In this blog post, you will be guided with the simplest method on how to perform the programmatic Google search using the open source python packages.

The following is the code snippet which demonstrates the usage of the most prominent packages for accomplishing the real-time Google search.

!python3 -m pip install googlesearch-python
Enter fullscreen mode Exit fullscreen mode


Let's get our hands dirty in working and solving the real problem. We need to search query to start with. Let us consider the following.

search_query = 'Sea food near Googleplex\n1600 Amphitheatre Parkway\nMountain View, CA 94043\nUnited States'
Enter fullscreen mode Exit fullscreen mode

Let's do the real time google search using the following code. We could also limit the number of interested results.

google_search_results = []
number_of_results = 2
from googlesearch import search
results = search(search_query, lang="en", num_results=number_of_results)
Enter fullscreen mode Exit fullscreen mode

Let's do some more results formatting to eliminate the unwanted results.

for result in results:
  if not result.startswith(""):
Enter fullscreen mode Exit fullscreen mode


Coming Next

Please refer to the below blog posts to perform the data extraction including the structured data extract using Google Gemini Pro LLM.


Top comments (0)