有道登陆解密

有道登陆解密_第1张图片

简单分析网页,可以发现password是通过加密在传输

有道登陆解密_第2张图片

我们开启debug调试,找到加密的js文件,拷贝下来,然后在我们程序中调用js文件得到返回值成功登陆有道登陆解密_第3张图片



import requests
import execjs

# http://account.youdao.com/login老接口地址
url = "https://logindict.youdao.com/login/acc/login"

# 读取js文件
with open("logincom.js", "r", encoding="utf-8") as f:
    js_str = f.read()
username = "*********"
password = "qwer1234QWER"

# 返回一个上下文
ctx = execjs.compile(js_str)

password = ctx.call("hex_md5", password)

# print(password)
data = {
    "app": "web",
    "tp": "urstoken",
    "cf": "3",
    "fr": "1",
    "ru": "http://dict.youdao.com/search?q=as&tab=#keyfrom=${keyfrom}",
    "product": "DICT",
    "type": "1",
    "um": "true",
    "username": username,
    "password": password
}

headers = {
    "User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36",
    "Referer":"http://account.youdao.com/login?service=dict&back_url=http%3A%2F%2Fdict.youdao.com%2Fsearch%3Fq%3Das%26tab%3D%23keyfrom%3D%24%7Bkeyfrom%7D",
    # "Cookie":"OUTFOX_SEARCH_USER_ID_NCOO=1082072868.6526275; [email protected]; YOUDAO_EAD_UUID=800e3e66-ce9f-442d-adbf-9b3979a21a3e; _ntes_nnid=2fe3d5c70463d0c7d9cb34cd85f28f28,1526368710759; JSESSIONID=abcyHuaJdyM6Db28go9ow; [email protected]|1527857737|2|mail163|11&19|shh&1527852495&youdaodict_client#shh&null#10#0#0|&0|youdaodict_client&mail163|[email protected]; ANTICSRF=cleared; DICT_LOGIN=8||1527889263933; DICT_FORCE=true; DICT_UGC=be3af0da19b5c5e6aa4e17bd8d90b28a|"
}


response = requests.post(url=url,data=data,headers=headers)
with open('网页登录.html','wb') as f:
    f.write(response.content)






你可能感兴趣的:(爬虫,加密,JavaScript,js,Python)