马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
360翻译import requests
import json
def req(mes):
data = {
'eng': 0,
'validate': '',
'ignore_trans': 0,
'query': mes,
}
headers = {
'Accept': 'application/json, text/plain, */*',
'Accept-Encoding': 'gzip,deflate',
'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
'Connection': 'keep-alive',
'Content-Length': '0',
'Cookie': 'Q_UDID=88eb521c-7152-f556-0b90-e6c89ba884de; __guid=144965027.914035386670474100.1589183201604.5356; count=4',
'Host': 'fanyi.so.com',
'Origin': 'http://fanyi.so.com',
'pro': 'fanyi',
'Referer': 'http://fanyi.so.com/',
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.14 Safari/537.36 Edg/83.0.478.13'
}
url = "http://fanyi.so.com/index/search?eng=0&validate=&ignore_trans=0&query=%E4%BD%A0%E5%A5%BD"
respoon = requests.post(url=url, headers=headers,
data=data).content.decode("utf-8")
print(json.loads(respoon)['data']['fanyi'])
if __name__ == "__main__":
while True:
req(input("需要翻译的句子:"))
headers只写ueser agent和pro 就行,但是我多写也不错
|