Perform search
Tags: #googlesearch #snippet
Author: Jeremy Ravenel

Input

Import library

1
try:
2
from googlesearch import search
3
except:
4
!pip install google
5
from googlesearch import search
Copied!

Variables

1
query = "telsa"
Copied!

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

1
for i in search(query, tld="co.in", num=30, stop=10, pause=2):
2
print(i)
Copied!
Copy link
Edit on GitHub