import json
import requests
url = "https://fanyi.baidu.com/sug"
headers = {
"User-Agent": 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1'
}
payload = {
"kw": "%s" % input("请输入要翻译的词:")
}
r = requests.post(url=url, headers=headers, data=payload)
print(r.text)
text_dict = json.loads(r.text)
k = text_dict.get("data")[0].get("k")
v = text_dict.get("data")[0].get("v")
print(k)
print(v)