从审查元素里看到的地址无法访问?
urllib模块做有道翻译题目时总是errorcode 50?从审查元素里看到的地址无法访问?
有没有同学遇到过类似问题
import urllib.request
import urllib.parse
url = "https://fanyi.youdao.com/translate_o?smartresult=dict&smartresult=rule"
data = {}
data['i'] = 'I love fishc.com'
data['from'] = 'AUTO'
data['to'] = 'AUTO'
data['smartresult'] = 'dict'
data['client'] = 'fanyideskweb'
data['salt'] = '16336833567020'
data['sign'] = '6a62493a0611c26807e89c434ec10d0d'
data['lts'] = '1633683356702'
data['bv'] = '361d3a19799ae6678a2de9a8326248a7'
data['doctype'] = 'json'
data['version'] = '2.1'
data['keyfrom'] = 'fanyi.web'
data['action'] = 'FY_BY_REALTlME'
head = {}
head['Accept'] = 'application/json, text/javascript, */*; q=0.01'
head['Accept-Encoding'] = 'gzip, deflate, br'
head['Accept-Language'] = 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6'
head['Connection'] = 'keep-alive'
head['Content-Length'] = '256'
head['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8'
head['Cookie'] = 'OUTFOX_SEARCH_USER_ID_NCOO=364072757.5997325; OUTFOX_SEARCH_USER_ID="1939145265@10.105.137.204"; _ga=GA1.2.998267744.1631616555; DICT_UGC=be3af0da19b5c5e6aa4e17bd8d90b28a|; JSESSIONID=abcXWfuMUifGAaLK8_EXx; user-from=http://www.youdao.com/; from-page=http://www.youdao.com/; ___rl__test__cookies=1633683356697'
head['Host'] = 'fanyi.youdao.com'
head['Origin'] = 'https://fanyi.youdao.com'
head['Referer'] = 'https://fanyi.youdao.com/'
head['sec-ch-ua'] = '"Chromium";v="94", "Microsoft Edge";v="94", ";Not A Brand";v="99"'
head['sec-ch-ua-mobile'] = '?0'
head['sec-ch-ua-platform'] = '"Windows"'
head['Sec-Fetch-Dest'] = 'empty'
head['Sec-Fetch-Mode'] = 'cors'
head['Sec-Fetch-Site'] = 'same-origin'
head['User-Agent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36 Edg/94.0.992.38'
head['X-Requested-With'] = 'XMLHttpRequest'
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) https://fanyi.youdao.com/translate_o?smartresult=dict&smartresult=rule
去掉_o。
另外咱论坛里有很多现成的有道爬虫作品,你可以参考参考。
https://fishc.com.cn/search.php?mod=forum&searchid=381&orderby=lastpost&ascdesc=desc&searchsubmit=yes&kw=%D3%D0%B5%C0%B7%AD%D2%EB 那个sign在每次请求时,需要计算才能得到结果
你直接复制粘贴肯定不行的 suchocolate 发表于 2021-10-8 18:05
https://fanyi.youdao.com/translate_o?smartresult=dict&smartresult=rule
去掉_o。
另外咱论坛里有很多 ...
请问这个_o是有什么说法?
{:5_106:} suchocolate 发表于 2021-10-8 18:05
https://fanyi.youdao.com/translate_o?smartresult=dict&smartresult=rule
去掉_o。
另外咱论坛里有很多 ...
哦。。看到论坛里的了,学习了。
页:
[1]