【发布时间】:2021-01-19 07:26:25
【问题描述】:
我实际上正在研究类似于 JARVIS 的 AI。我想从谷歌那里抓取答案,这样当我向我的 AI 提出问题时;它会说出问题的答案。例如,如果我在 Google 上搜索“Google 属于哪个国家/地区?”谷歌只是说“加利福尼亚”。我尝试了一个谷歌模块来使用这个类来提取信息:
class Gsearch_python:
def __init__(self,name_search):
self.name = name_search
def Gsearch(self):
count = 0
try :
from googlesearch import search
except ImportError:
print("No Module named 'google' Found")
for i in search(query=self.name,tld='co.in',lang='en',num=10,stop=1,pause=2):
count += 1
print (count)
print(i + '\n')
gs = Gsearch_python('google belongs to which country')
gs.Gsearch()
【问题讨论】:
-
查看 selenium 看看是否有帮助。您也可以简单地使用
city to country库来获取您感兴趣的国家/地区。 -
@AzyCrw4282 谢谢它的工作!但如果 jarvis 也能像谷歌助手那样说出结果会更好......
标签: python beautifulsoup google-search