问题描述
我正在尝试创建类似于Google Home或Alexa的语音激活AI,我可以将其与很酷的东西配对,但是我在编码部分要好得多,而不是抓取功能,所以即时消息不是非常有经验,现在我正在工作关于它的功能,此功能将告诉您营业时间以及是否营业,但似乎每当我提出要求时,它可能会隐藏一些html,尤其是我需要的html,因此它返回None。现在我在树莓派4上即时通讯,所以我真的不想经历下载硒的麻烦,尤其是它的驱动程序,是否有解决此问题的方法,还是我应该使用其他网络抓取工具,例如scrapy或其他?如果我需要即时消息,请参阅其他编码语言的建议。
def service(self,business):
url = requests.get('https://www.google.com/search?q={}+hours'.format(business))
outputs = []
if url.status_code == 200:
soup = bs4.BeautifulSoup(url.text,"lxml")
#span class below is the class that contains the text that contains the hours shown for that day or jus displays closed
string = soup.find('span',attrs={'class': 'TLou0b JjSWRd'})
print(string)
#returns None
if url.status_code == 404:
print('Error')
return 'Error 404'
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)