Its quite handy to perform a google search using python. It shows the top URLs for the required query.
pip install beautifulsoup4
pip install google
search(query, tld='com', lang='en', num=10, start=0, stop=None, pause=2.0)
-Install the given libraries
-Download the code from the given github repository
-Run the code
-Enter your desired search
try:
from googlesearch import search
except ImportError:
print("No module named 'google' found")
This code fragment tries to import the search function from googlesearch module and throws and error if for any issue the module couldn't be imported.
print("Enter the topic to search: ")
query = input()
Taking input from the user. The user can input their desired search in the search option.
for j in search(query, tld="co.in", num=10, stop=10, pause=2):
print(j)
The search function returns the URLs of all the relevant searches.