登录之后,打印侧边栏。
import requests
import re
# 构造 Request headers
agent = 'Mozilla/5.0 (Windows NT 5.1; rv:33.0) Gecko/20100101 Firefox/33.0'
headers = {
'User-Agent': agent
}
session = requests.session()
def login(email, secret):
session.get("http://126.com", headers=headers)
params = {
'df': 'mail126_letter',
'from': 'web',
'funcid': 'loginone',
'iframe': '1',
'language': '-1',
'passtype': '1',
'product': 'mail126',
'verifycookie': '-1',
'net': 'failed',
'style': '-1',
'race': '-2_-2_-2_db',
'uid': email,
'hid': '10010102'
}
postdata = {
"username": email,
"savelogin": "1",
"url2": "http://mail.126.com/errorpage/error126.htm",
"password": secret
}
url = "https://mail.126.com/entry/cgi/ntesdoor?"
login = session.post(url, data=postdata, headers=headers, params=params)
pa = r'href = "(.*?)"'
res = re.findall(pa, login.text)
index_page = session.get(res[0])
pa_index = r"('messageCount'.*?).*?('unreadMessageCount'.*?),"
res_index = re.findall(pa_index, index_page.text)
print(res_index)
return index_page
try:
input = raw_input
except:
pass
if __name__ == '__main__':
email = input('请输入你的 email\n> ')
secret = input("请输入你的密码\n> ")
login(email, secret)
故意输错3次之后,会出现依次选字的验证码,尚未解决
网易易盾还没有解决,不过检查元素之后,感觉和之前的差不多。