爬有道翻译
import urllib.requestimport urllib.parse
content = input('请输入要翻译的内容:')
url = 'http://fanyi.youdao.com/translate_o?smartresult=dict&smartresult=rule'
date = {}
date['i']=content
date['from']='AUTO'
date['to']='AUTO'
date['smartresult']='dict'
date['client']='fanyideskweb'
date['salt']='15979913254708'
date['sign']='fe5f00b4f6da188ae071a5f15f239354'
date['lts']='1597991325470'
date['bv']='cc652a2ad669c22da983a705e3bca726'
date['doctype']='json'
date['version']='2.1'
date['keyfrom']='fanyi.web'
date['action']='FY_BY_CLICKBUTTION'
date = urllib.parse.urlencode(date).encode('utf-8')
response = urllib.request.urlopen(url,date)
html = response.read()
print(html)
爬出来结果:
请输入要翻译的内容:我爱你
b'{"errorCode":50}'
>>>
这是有道搞得鬼吗
import urllib.request
import urllib.parse
content = input('请输入要翻译的内容:')
url = 'http://fanyi.youdao.com/translate?smartresult=dict&smartresult=rule'
date = {}
date['i']=content
date['from']='AUTO'
date['to']='AUTO'
date['smartresult']='dict'
date['client']='fanyideskweb'
date['salt']='15979913254708'
date['sign']='fe5f00b4f6da188ae071a5f15f239354'
date['lts']='1597991325470'
date['bv']='cc652a2ad669c22da983a705e3bca726'
date['doctype']='json'
date['version']='2.1'
date['keyfrom']='fanyi.web'
date['action']='FY_BY_CLICKBUTTION'
date = urllib.parse.urlencode(date).encode('utf-8')
response = urllib.request.urlopen(url,date)
html = response.read()
print(html)
Hello. 发表于 2020-8-21 18:12
url = 'http://fanyi.youdao.com/translate_o?smartresult=dict&smartresult=rule'
url = 'http://fanyi.youdao.com/translate?smartresult=dict&smartresult=rule'
为什么你少了个_o ?
可是网页上有,有什么区别吗?
页:
[1]