urllib_post请求百度翻译详细翻译

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

import urllib.request
import urllib.parse
url='https://fanyi.baidu.com/v2transapi?from=en&to=zh'
headers={
'Cookie': 'BIDUPSID=4051DD61A35ADB02F6DBB9362C65230B; PSTM=1691472145; BAIDUID=4051DD61A35ADB02E71B03D86B63E5F3:FG=1; REALTIME_TRANS_SWITCH=1; FANYI_WORD_SWITCH=1; HISTORY_SWITCH=1; SOUND_SPD_SWITCH=1; SOUND_PREFER_SWITCH=1; APPGUIDE_10_7_2=1; smallFlowVersion=old; BDUSS=25reVZxN3puRTlZRmVkYkNpQ2REYkx1TFRyYk8wd3d-ei1ON3RGMjdwUnFyRzVtRUFBQUFBJCQAAAAAAQAAAAEAAABEqXCBU3djbWIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGofR2ZqH0dmd; BDUSS_BFESS=25reVZxN3puRTlZRmVkYkNpQ2REYkx1TFRyYk8wd3d-ei1ON3RGMjdwUnFyRzVtRUFBQUFBJCQAAAAAAQAAAAEAAABEqXCBU3djbWIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGofR2ZqH0dmd; APPGUIDE_10_7_8=1; APPGUIDE_10_7_1=1; MCITY=-286%3A; H_PS_PSSID=60277_60361; H_WISE_SIDS=60277_60361; H_WISE_SIDS_BFESS=60277_60361; BDORZ=FAE1F8CFA4E8841CC28A015FEAEE495D; BA_HECTOR=21ah200120840584ak05050h0s6f6o1j975q01v; ZFY=6TGjMTdRv2Hm2U6qBurH:ANpw:BH01zqfPCmxsI4SsNxs:C; BAIDUID_BFESS=4051DD61A35ADB02E71B03D86B63E5F3:FG=1; BDRCVFR[feWj1Vr5u3D]=I67x6TjHwwYf0; PSINO=2; delPer=0; ab_sr=1.0.1_YjllYzZiNGZmMGQ3Y2MzYTA3ZGZiN2U4YzJhMDRlNzI1MjM2Nzk4ZmI3ZDI3NzQ0N2Y3MmQ5NzdmYTJlYjlhNzgwZjMxY2IyMjg3NmMzZjI5MTljN2U2ZDRmMmU2N2NmMmUxMDZhZjI0NTFmM2RhNTgxMjVmNTU4ZDM4Y2IxNzY2MDczODkyNzU3YWM2NDI3ZjIwNzgwOTVhNmJmNmVjNDM3ZWJlY2U2MjM2Nzg3MjcyZTM3ZWM4MjI0MzYxNzEx'
}

data={
'from': 'en',
'to': 'zh',
'query': 'love',
'transtype': 'realtime',
'simple_means_flag': '3',
'sign': '198772.518981',
'token': 'e4649cb1ca39571638fbe20768a03def',
'domain': 'common',
'ts': '1720950443458'
}
data=urllib.parse.urlencode(data).encode('utf-8')
req=urllib.request.Request(url,data,headers)
res=urllib.request.urlopen(req)
html=res.read().decode('utf-8')
#print(html)#'errmsg': '未知错误'
import json
html=json.loads(html)
print(html)


urllib_post请求百度翻译详细翻译
https://ianwusb.blog/2024/07/26/urllib_post请求百度翻译详细翻译/
作者
Ianwusb
发布于
2024年7月26日
许可协议