How to integrate Google with Python?

In a general scenario when we want to get to know about something what we do is go to Google and type the sentence or word which will show us many results but searching for the information in each and every page is a hectic task so what is the solution for this problem???

In this blog let us see how can we search on google or get redirected to the pages to google via python.

This can be done just through three to four lines of code.

Prerequisites for implementation is:

install the google library via terminal in your compiler.

For visual understanding you may refer:

Implementation of Google Search Via Python
pip install google
pip install google

now the second step is to import the search from googlesearch

from googlesearch import search

now in the next step we need to create a variable called “Query” which will hold the topic which we are searching for.

query = "prequelcoding"

now in order to generate multiple links we are going to use the for loop.

for url in search(query):  #here whenever our query is matching with the search in Google link will be generated in our output.

now the last step is to print this links which we have executed in the for loop.

print(url)

Full Code:

from googlesearch import search

query = "prequelcoding"
for url in search(query):
 print(url)

How to integrate Google with Python?
Scroll to top