'Python, googlesearch module can not find correct url
So, what I'm trying to do is to open the first result of every search in google via python to access its website. Everything works fine until I insert the keyword "gmail", it's always opens a Wikipedia page like this. I wonder if this is related to my region or this is the limit of the googlesearch module, and can someone give me any solution to fix this?
import webbrowser
from googlesearch import search
def open_website(name):
def get_website(name):
try:
for web in search(name,stop=1):
webbrowser.open(web)
return True
except Exception:
return "I can't open your website, check your connection"
if get_website(name) == None:
return("Your website doesn't exist")
else:
return "Opening "+name+"..."
open_website("gmail") #you can use "facebook", "instagram", "duolingo" or something like that
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
