1.post方式地址、json返回数据
2.post方式传给服务器的数据
3.完整代码
# post方法获取百度返回返回的ajax数据
import requests
url = "https://fanyi.baidu.com/sug"
headers = {
"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36"
}
word = input("enter a word:")
data = {
"kw": word
}
resp = requests.post(url=url,data=data,headers=headers)
print(resp.json())