在命令行里直接get就能获取信息,写成下面的程序就要人机验证了,这是为什么?
import requests
keyword = "Python"
try:
kv = {'wd': keyword}
kv2 = {'user-agent': 'Mozilla/5.0'}
r = requests.get("http://www.baidu.com/s", params=kv, headers=kv2)
r.raise_for_status()
r.encoding = r.apparent_encoding
print(r.text)
except:
print("爬取失败")