import requests url = 'https://fanyi.baidu.com/sug' #UA伪装: 让爬虫对应的请求载体标识伪装成一款浏览器,将对应的User-Agent封装到字典 headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36' } kw = input('请输入一字关键词:') data = { 'kw': kw } response = requests.post(url,data=data,headers=headers) dic = response.json() print(dic)
标签:翻译,headers,537.36,实验,User,kw,data,response,百度 From: https://www.cnblogs.com/145g/p/16894484.html