神仙打架 发表于 2020-3-16 10:56
不看弹幕嘛,把url的 _o去掉就可以了
现在from data 下面的东西都变了好吧
神仙打架 发表于 2020-3-16 10:56
不看弹幕嘛,把url的 _o去掉就可以了
试了一下,新版的按照甲鱼的格式做就行,然后把UTf的内容按甲鱼的方法加进去,最后去掉_o.就可以了
如果返回的是{"errorCode":50}是怎么回事呢?
代码:
import urllib.request
import urllib.parse
url = 'http://fanyi.youdao.com/translate_o?smartresult=dict&smartresult=rule'
data = {}
data['i'] ='my love'
data['from'] = 'AUTO'
data['to'] ='AUTO'
data['smartresult'] = 'dict'
data['client'] = 'fanyideskweb'
data['salt'] = '15863503013953'
data['sign'] = 'bb170ea2c0e9015f63be57b06c8f0537'
data['ts'] = '1586350301395'
data['bv'] = 'e3024dc52ff5c694b77471a08006ba92'
data['doctype'] = 'json'
data['version'] = '2.1'
data['keyfrom'] = 'fanyi.web'
data['action'] = 'FY_BY_CLICKBUTTION'
data = urllib.parse.urlencode(data).encode('utf-8')
response = urllib.request.urlopen(url,data)
html = response.read().decode('utf-8')
print(html)
SLD1399 发表于 2020-4-8 21:27
如果返回的是{"errorCode":50}是怎么回事呢?
代码:
去掉_o
curry_305 发表于 2020-3-20 12:03
import urllib.request
import urllib.parse
去掉_o(url的)
{:10_254:}
优秀!浅显易懂!
明白了,换python3可解决大部分编码问题{:10_279:}
学习了~{:5_108:}
插眼 小甲鱼牛逼
1
谢谢哥(òó)
2021.8.30来冒个泡
new bee
{:10_279:}
import urllib.request
import urllib.parse
import json
content = input('请输入需要翻译的内容:')
url = 'https://fanyi.youdao.com/translate'
data = {}
data['from'] = 'AUTO'
data['smartresult'] = 'dict'
data['i'] = content
data['doctype'] = 'json'
data['version'] = '2.1'
data['keyfrom'] = 'fanyi.web'
data['ue'] = 'UTF-8'
data['action'] = ['FY_BY_REALTlME']
data = urllib.parse.urlencode(data).encode('utf-8')
response = urllib.request.urlopen(url,data)
html = response.read().decode('utf-8')
target = json.loads(html)
print("翻译结果:%s"%(target['translateResult']['tgt']))
成功了,但是翻译的速度很慢很慢,是那个环节出问题了啊
666666666
python3牛逼呀
学习了,感谢分享