代码拉取完成,页面将自动刷新
import requests as rep
import hashlib
"""
搜狗
py3.6
ning
"""
url = 'https://fanyi.sogou.com/api/transpc/text/result'
header = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36',
'Cookie': 'SUID=38A253DE374A910A0000000062B92DEF; IPLOC=CN4514; ld=Tlllllllll20xsrcYZbElLGpMsP0xs7RHw1DDkllll9llllxpylll5@@@@@@@@@@; cd=1661401859&11982e2b8c2c5be41a8fa9cd08465a62; rd=olllllllll20xsrcYZbf@pGpMsP0xs7RHw1DDkllll9lllljpylll5@@@@@@@@@@; ABTEST=0|1662796799|v17; SNUID=BDBF0F3782876BCC8E1012E28365D2D0; wuid=1662796799635; FQV=8eb7a3f5b31d5332ec812fadbc8f7a82; translate.sess=b3742e9e-fe08-4815-9666-ab09f18b3fbc; SUV=1662796800244; SGINPUT_UPSCREEN=1662796800258'
}
def get_md5(text):
text = 'autoen' + text + '109984457'
hl = hashlib.md5()
hl.update(text.encode(encoding='utf-8'))
sign = hl.hexdigest()
return sign
def get_sodog(text):
data = {
'client': "pc",
'exchange': 'false',
'fr': "browser_pc",
'from': "auto",
'needQc': 1,
's': get_md5(text),
'text': text,
'to': "en",
'uuid': "4150e2d0-f5f3-4e49-9b10-f77d2910e688"
}
my_text = rep.post(url=url, headers=header, json=data).json()
print(my_text['data']['translate']['dit'])
if __name__ == '__main__':
while True:
text = input('请输入想翻译的:')
get_sodog(text)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。