|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
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)
我通过以上代码运行有道翻译,返回的字典总是{"errorCode":50}
|
|