尝试搜索Yahoo时出错

时间:2019-04-25 16:09:52

标签: python python-requests

我正在尝试使用以下代码在Yahoo中搜索查询:

import re
import requests

query = "deep"
yahoo = "https://search.yahoo.com/search?q=" + query
raw_page = requests.get(yahoo) 

但是我收到这样的错误:

  

TypeError: init ()得到了意外的关键字参数'strict'

该错误发生在最后一行。我该如何解决?

编辑

这是整个代码:

import re
import requests

no = 10
query = "deep"
yahoo = "https://search.yahoo.com/search?q=" + query + "&n=" + str(no)
#yahoo = "https://search.yahoo.com/search?p=" + query
raw_page = requests.get(yahoo) 
results = re.findall(r'(?<=<h3 class="r"><a href="/url\?q=).*?(?=&amp)', str(raw_page))
res = list(set(results))[0:30] #Provides 30 unique of the 35 we requested above

print(res)

这是错误轨道:

enter image description here

1 个答案:

答案 0 :(得分:2)

根据this个随机github问题,您可能需要将您的请求库更新为最新版本 即。 # pip install requests -U