小白求助urllib.request 问题
为啥我按照视频一模一样敲会报错呢import urllib.request
import urllib.parse
url = 'https://fanyi.youdao.com/translate_o?smartresult=dict&smartresult=rule'
data = {}
data['i'] = 'i love'
data['from'] = 'AUTO'
data['to'] = 'AUTO'
data['smartresult'] = 'dict'
data['client'] = 'fanyideskweb'
data['salt'] = '16492590315893'
data['sign'] = '9c31356a04f5a273e9503a20369ad4e6'
data['lts'] = '1649259031589'
data['bv'] = '656f750600466990f874a839d9f5ad23'
data['doctype'] = 'json'
data['version'] = '2.1'
data['keyfrom'] = 'fanyi.web'
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')
print(html)
{"errorCode":50}
发现'https://fanyi.youdao.com/translate_o?smartresult=dict&smartresult=rule' 就是不能访问的,但是翻译页面的网页显示的就是这个链接啊
因为过时了。网站都会改版,反爬。 看看这还能不能用吧。
https://fishc.com.cn/forum.php?mod=viewthread&tid=93823&highlight=%D3%D0%B5%C0 本帖最后由 isdkz 于 2022-4-7 00:01 编辑
因为那个不是真正的接口
import urllib.request
import urllib.parse
url = 'https://fanyi.youdao.com/translate?smartresult=dict&smartresult=rule' # 把 translate_o 中的 _o 去掉
data = {}
data['i'] = 'i love'
data['from'] = 'AUTO'
data['to'] = 'AUTO'
data['smartresult'] = 'dict'
data['client'] = 'fanyideskweb'
data['salt'] = '16492590315893'
data['sign'] = '9c31356a04f5a273e9503a20369ad4e6'
data['lts'] = '1649259031589'
data['bv'] = '656f750600466990f874a839d9f5ad23'
data['doctype'] = 'json'
data['version'] = '2.1'
data['keyfrom'] = 'fanyi.web'
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')
print(html)
isdkz 发表于 2022-4-6 23:59
因为那个不是真正的接口
这样试了一下可以了,高手啊,你是怎么发现真正接口的啊 15979152851 发表于 2022-4-8 10:40
这样试了一下可以了,高手啊,你是怎么发现真正接口的啊
这算是一个后门吧,具体你得问有道
页:
[1]