|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
import urllib.request as ur
import urllib.parse as up
import json
url = 'http://fanyi.youdao.com/translate?smartresult=dict&smartresult=rule&smartresult=ugc'
data = {
"type" : "AUTO",
"i" : 'hello',
"doctype" : "json",
"xmlVersion" : "1.8",
"keyfrom" : "fanyi.web",
"ue" : "UTF-8",
"action" : "FY_BY_CLICKBUTTON",
"typoResult" : "true"}
data = up.urlencode(data).encode('utf-8')
response = ur.urlopen(url, data)
html = response.read().decode('utf-8')
target = json.loads(html)
print(target)
运行结果是
{'type': 'EN2ZH_CN', 'errorCode': 30, 'elapsedTime': 0, 'translateResult': [[{'src': '您的请求来源非法,商业用途使用请关注有道翻译API官方网站“有道智云”: http://ai.youdao.com', 'tgt': '您的请求来源非法,商业用途使用请关注有道翻译API官方网站“有道智云”: http://ai.youdao.com'}]]}
您的请求来源非法,商业用途使用请关注有道翻译API官方网站
说得很清楚了,反爬就得先解密。
练习还是换网站吧。
|
|