zjh100 发表于 2020-5-22 14:33:20

为何总是返回error

我用以下代码访问有道翻译
import urllib.request
import urllib.parse

url= 'http://fanyi.youdao.com/translate_o?smartresult=dict&smartresult=rule'
data={}
head={}
head['User-Agent']='Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36'
data['i']='I love her'
data['from']='AUTO'
data['to']='AUTO'
data['smartresult']='dict'
data['client']='fanyideskweb'
data['salt']='15898959710302'
data['sign']='8e60fad0d808940174613209daf84e81'
data['ts']='1589895971030'
data['bv']='cc652a2ad669c22da983a705e3bca726'
data['doctype']='json'
data['version']='2.1'
data['keyfrom']='fanyi.web'
data['action']='FY_BY_CLICKBUTTION'
data=urllib.parse.urlencode(data).encode('utf-8')
req=urllib.request.Request(url,data,head)
response=urllib.request.urlopen(req)
html=response.read().decode('utf-8')
print(html)
以上源自审查元素的from data等
为啥返回的字符串永远是{"errorCode":50}

suchocolate 发表于 2020-5-23 09:00:51

url= 'http://fanyi.youdao.com/translate?smartresult=dict&smartresult=rule'
# 有道的反扒,需要去掉_o
页: [1]
查看完整版本: 为何总是返回error