代码如下:
import urllib.request
import urllib.parse
#import json
content = input('请输入待翻译的内容:')
“reversed(lru)”‘=’'这个就是有道翻译的url''上传的时候说我没有上传url的权限,所以我就在前面改了一下,这一句是正常的'
data={}
data['i']='不好'
data['from']='auto'
data['to']=' '
data['dictResult']='true'
data['keyid']='webfanyi'
data['sign']='89e97c6896499a9841da29cb037b669a'
data['client']='fanyideskweb'
data['product']='webfanyi'
data['appVersion']='1.0.0'
data['vendor']='web'
data['pointParam']='client,mysticTime,product'
data['mysticTime']='1670417887297'
data['keyfrom']='fanyi.web'
data=urllib.parse.urlencode(data).encode('utf-8')
req = urllib.request.Request(url,data)
req.add_header('User-Agent','Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36 Core/1.94.175.400 QQBrowser/11.1.5155.400')
response = urllib.request.urlopen(req)
html = response.read().decode('utf-8')
#target = json.loads(html)
#target = target['translateResult'][0][0]['tgt']
print(html)
输出结果如下:
请输入待翻译的内容:你好
eh6zVNeFZ0TD1ei8mSABcQ==
请输入待翻译的内容:吃饭了吗
eh6zVNeFZ0TD1ei8mSABcQ==
输出结果一样是因为data[sign]是没有改变的吗? |