Links

Perform search

Tags: #googlesearch #snippet #operations #url
Author: Jeremy Ravenel
Description: This notebook allows users to perform Google searches quickly and easily.

Input

Import library

try:
from googlesearch import search
except:
!pip install google
from googlesearch import search

Variables

query = "telsa"

Model

Parameters :
  • query: This is the text that you want to search for.
  • tld: This refers to the top level domain value like co.in or com which will specify which Google website we want to use.
  • lang: This parameter stands for language.
  • num: This is used to specify the number of results we want.
  • start: This is to specify from where to start the results. We should keep it 0 to begin from the very start.
  • stop: The last result to retrieve. Use None to keep searching forever.
  • pause: This parameter is used to specify the number of seconds to pause between consecutive HTTP requests because if we hit too many requests, Google can block our IP address.
The above function will return a python generator (iterator) which has the search result URLs.
Source : https://www.studytonight.com/post/how-to-perform-google-search-using-python#

Output

for i in search(query, tld="co.in", num=30, stop=10, pause=2):
print(i)