【笔记整理】[案例]爱词霸翻译post请求
import json
if __name__ == '__main__':
import requests
resp = requests.post(
url="http://ifanyi.iciba.com/index.php?c=trans&m=fy&client=6&auth_user=key_web_fanyi&sign=3b48dbb7ba810dd9",
data={
'from': 'zh', # 表示被翻译的语言是自动识别
'to': 'en', # 表示翻译后的语言是自动识别
'q': '牛逼' # 要翻译的中文字符串
}, headers={
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/114.0",
"referer": "http://www.iciba.com"
})
json_dict: dict = json.loads(resp.content)
print(json_dict["content"]["out"])
本文来自博客园,作者:蕝戀,转载请注明原文链接:https://www.cnblogs.com/juelian/p/17559486.html