我在Python里爬虫一直出现连接超时,但是浏览器是可以打开的
Opened this issue · 2 comments
liu120945561 commented
我在Python里爬虫一直出现连接超时,但是浏览器是可以打开的,请问是怎么回事~~~~
nlpdz commented
这是我写的爬虫代码,测试可以用。
import json
import requests
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36',
}
url = 'http://39.108.91.172:9004/?inputStr=乙肝和冠心病那个严重'
def getData():
jsonData = requests.get(url, headers=headers).text
return(json.loads(jsonData))
if name == 'main':
jsonData = getData()
print(jsonData)
print(jsonData["entities"][0]["word"])
liu120945561 commented
有发啥论文吗,我引用下哈哈哈哈