|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
import urllib.request
import urllib.parse
#url中的translate后加_o就获取不到信息了,为什么,而且浏览器查看的时候是有_o的啊
url = "http://fanyi.youdao.com/translate_0?smartresult=dict&smartresult=rule"
head_data = {
"action":"FY_BY_REALTIME",
"client":"fanyideskweb",
"doctype":"json",
"from":"AUTO",
"i":"i love fishc.com",
"keyfrom":"fanyi.web",
"salt":"1527830985079",
"sign":"3825b3cd1159b61b86ab1fa8a261357f",
"smartresult":"dict",
"to":"AUTO",
"typoResult":"false",
"version":"2.1",
}
data = urllib.parse.urlencode(head_data).encode("utf-8")
req = urllib.request.Request(url,data)
req.add_header("User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/17.17134")
request = urllib.request.urlopen(req)
html = request.read().decode("utf-8")
print(html)
直接访问那个网址也会显示errorcode,去了_o才会到主页
|
|