import
requests
headers
=
{
'Accept-Language'
:
'zh-CN,zh;q=0.9'
,
'Connection'
:
'keep-alive'
,
'Content-Type'
:
'application/json'
,
'Origin'
:
'https://fanyi.baidu.com'
,
'Referer'
: '',
'Sec-Fetch-Dest'
:
'empty'
,
'Sec-Fetch-Mode'
:
'cors'
,
'Sec-Fetch-Site'
:
'same-origin'
,
'User-Agent'
:
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.6261.95 Safari/537.36'
,
'accept'
:
'text/event-stream'
,
'sec-ch-ua'
:
'"Chromium";v="122", "Not(A:Brand";v="24", "Google Chrome";v="122"'
,
'sec-ch-ua-mobile'
:
'?0'
,
'sec-ch-ua-platform'
:
'"Windows"'
,
}
json_data
=
{
'query'
:
'大家好才是真的好'
,
'from'
:
'zh'
,
'to'
:
'en'
,
'reference'
: '',
'corpusIds'
: [],
'needPhonetic'
:
True
,
'domain'
:
'common'
,
'milliTimestamp'
:
1733901013945
,
}
response
=
requests.post(
'https://fanyi.baidu.com/ait/text/translate'
, headers
=
headers, json
=
json_data)
print
(response.text)