|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- import urllib.request as request
- import urllib.parse as parse
- url = 'http://fanyi.youdao.com/translate_o?smartresult=dict&smartresult=rule&sessionFrom=https://www.baidu.com/link';
- head = {}
- head['User-Agent'] = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36'
- data = {}
- data['i'] = 'fish'
- data['from'] = 'AUTO'
- data['to'] ='AUTO'
- data['smartresult'] = 'dict'
- data['client'] = 'fanyideskweb'
- data['salt'] = '1498366323659'
- data['sign'] = '5aeaa351d3d7d7a7d9e323a2be47393c'
- data['doctype'] = 'json'
- data['version'] = '2.1'
- data['keyfrom'] = 'fanyi.web'
- data['action'] = 'FY_BY_CLICKBUTTON'
- data['typoResult'] = 'true'
- data = parse.urlencode(data).encode('utf-8')
- req = request.Request(url,data,head)
- #req.add_header('User-Agent','Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36')
- response = request.urlopen(req)
- html = response.read().decode('utf-8')
- print(html)
复制代码
运行结果:{"errorCode":50}。。。
|
|