Google Search API in Python 3
![]() |
| [image source: https://towardsdatascience.com/current-google-search-packages-using-python-3-7-a-simple-tutorial-3606e459e0d4] |
Install the Google package in python:
pip install google
Code:
try :
from googlesearch import search
except ImportError:
print("No Module named 'google' Found")
count = 0
for i in search(query="devharsh", tld='co.in', lang='en'):
count += 1
print(i)
if(count > 20):
break
Output:
(base) devharsh@Devharshs-MBP Downloads % python google_search.py
http://devharshinfotech.com/
http://devharshinfotech.com/aboutus.html
http://devharshinfotech.com/services.html
http://devharshinfotech.com/banking.html
http://devharshinfotech.com/clients.html
https://www.linkedin.com/company/devharsh-infotech-pvt-ltd-
https://www.facebook.com/devharshinfotech/
https://www.glassdoor.com/Overview/Working-at-Devharsh-Infotech-EI_IE1489739.11,28.htm
https://www.zaubacorp.com/company/DEVHARSH-INFOTECH-PRIVATE-LIMITED/U30007MH2004PTC146993
https://www.devharshinfotech.co.in/
https://www.justdial.com/Mumbai/Devharsh-Infotech-Pvt-Ltd-Near-Jaswanti-Landmark-Vikhroli-West/022PXX22-XX22-180816132003-K8B9_BZDET
https://www.indeed.co.in/Devharsh-Infotech-Pvt-Ltd,-Vikroli,-West-jobs-in-Vikhroli,-Mumbai,-Maharashtra
https://www.indiamart.com/luckyforms/profile.html
https://www.dnb.com/business-directory/company-profiles.devharsh_infotech_private_limited.4573fff3e216bfdf56a77b57d67fd683.html
https://panjiva.com/Devharsh-Infotech-Pvt-Ltd/30939713
https://www.fundoodata.com/companies-detail/Devharsh-Infotech-Pvt-Ltd/101820.html
https://www.zoominfo.com/c/devharsh-infotech-limited/358353372
https://github.com/devharsh
https://www.indiamart.com/devharsh-infotech-ltd/
https://hamariweb.com/names/hindu/hindi/boy/devharsh-meaning_25329
http://www.babynology.com/name/devharsh-m.html
This example runs Google searches from Python using the googlesearch package, iterating over result links for a query, with installation through a single pip command.
It is handy for quick scripting and prototyping. For production, remember that scraping search results can be rate limited or blocked, and Google offers official programmable search APIs for reliable access.

Comments
Post a Comment