LearnL
发表于 2020-4-4 15:26:40
神仙打架 发表于 2020-3-16 10:56
不看弹幕嘛,把url的 _o去掉就可以了
试了一下,新版的按照甲鱼的格式做就行,然后把UTf的内容按甲鱼的方法加进去,最后去掉_o.就可以了
SLD1399
发表于 2020-4-8 21:27:03
如果返回的是{"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:29:25
SLD1399 发表于 2020-4-8 21:27
如果返回的是{"errorCode":50}是怎么回事呢?
代码:
去掉_o
SLD1399
发表于 2020-4-8 21:30:11
curry_305 发表于 2020-3-20 12:03
import urllib.request
import urllib.parse
去掉_o(url的)
小甲鱼{i}号
发表于 2020-5-13 09:54:12
{:10_254:}
爱笑的皮卡媛
发表于 2020-5-24 17:47:44
优秀!浅显易懂!
叱咤风云2333
发表于 2020-5-31 11:48:24
明白了,换python3可解决大部分编码问题{:10_279:}
枫叶红于二月花
发表于 2020-9-1 16:38:25
学习了~{:5_108:}
zhangfeiwen
发表于 2020-10-13 13:12:57
插眼 小甲鱼牛逼
小银河酱
发表于 2021-5-6 15:38:15
1
zhangk63
发表于 2021-6-26 16:36:23
谢谢哥(òó)
1806192836
发表于 2021-8-18 20:31:53
2021.8.30来冒个泡
Halao0
发表于 2021-9-29 11:22:50
new bee
TGgan
发表于 2021-11-18 15:06:19
{:10_279:}
KoongMing
发表于 2022-7-3 14:46:16
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']))
成功了,但是翻译的速度很慢很慢,是那个环节出问题了啊
danny_wen
发表于 2022-7-4 00:43:54
666666666
Vicissitude357
发表于 2022-9-10 10:53:41
python3牛逼呀
小野人闯迷宫
发表于 2022-12-2 10:50:16
学习了,感谢分享