网易邮箱的模拟登录和收信都非常简单,在阅读邮件的时候需要两个参数:_ntes_nnid 和 _ntes_nuid
_ntes_nnid=21533f97b25070a31c249f59513ad20c,1492592485123
_ntes_nuid=21533f97b25070a31c249f59513ad20c
32位的,看着像MD5加密。还请各位大神不吝赐教!
下面是阅读邮件的代码:
请求头信息:
Host:
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/0101 Firefox/52.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Referer: /js6/main.jsp?sid=JBotLILIiJUXeLousXIIzvphyyqrIzxb&df=email163
Connection: keep-alive
Upgrade-Insecure-Requests: 1
★ sid是登录时给的
Cookies:
mail_health_check_time=1492592481181
JSESSIONID=3974283F6837B413D68C3980400C0D87
SID=793490e4-a2cf-494c-afe6-0755b6b2bf2d
P_INFO=lst_d9c@|1492592479|0|mail163|00&99|shd&1492585407&mail163#shd&370800#10#0#0|&0|mail163|lst_d9c@
S_INFO=1492592479|0|2&70##|lst_d9c
NTES_SESS=R0AofYsxryOBQctfrmVvpre0BCTU413FzX9.ZwrFyShYAZ_WA7Kw6gNj9oCelkHrPVajggmcNeD4f0uTMaehyteJca0yQXHhlSHoVCBtHlwC4s63GNk31zaDmRzFjgVBRkqleTL3wF9thkMkq3f483J7WC8Cl9wKn
mail_upx=t11hz.|t12hz.|t13hz.|t1hz.|t2hz.|t4hz.|t5hz.|t6hz.|t7hz.|t8hz.|t10hz.|c7bj.|c1bj.|c2bj.|c3bj.|c4bj.|c5bj.|c6bj.
mail_upx_nf=
mail_idc=
Coremail=1492592479840%JBotLILIiJUXeLousXIIzvphyyqrIzxb%g7a58.
MAIL_MISC=lst_d9c
cm_last_info=dT1sc3RfZDljJTQwMTYzLmNvbSZkPWh0dHAlM0ElMkYlMkZtYWlsLjE2My5jb20lMkZqczYlMkZtYWluLmpzcCUzRnNpZCUzREpCb3RMSUxJaUpVWGVMb3VzWElJenZwaHl5cXJJenhiJnM9SkJvdExJTElpSlVYZUxvdXNYSUl6dnBoeXlxckl6eGImaD1odHRwJTNBJTJGJTJGbWFpbC4xNjMuY29tJTJGanM2JTJGbWFpbi5qc3AlM0ZzaWQlM0RKQm90TElMSWlKVVhlTG91c1hJSXp2cGh5eXFySXp4YiZ3PW1haWwuMTYzLmNvbSZsPS0xJnQ9LTEmbj1j
MAIL_SESS=R0AofYsxryOBQctfrmVvpre0BCTU413FzX9.ZwrFyShYAZ_WA7Kw6gNj9oCelkHrPVajggmcNeD4f0uTMaehyteJca0yQXHhlSHoVCBtHlwC4s63GNk31zaDmRzFjgVBRkqleTL3wF9thkMkq3f483J7WC8Cl9wKn
MAIL_SINFO=1492592479|0|2&70##|lst_d9c
MAIL_PINFO=lst_d9c@|1492592479|0|mail163|00&99|shd&1492585407&mail163#shd&370800#10#0#0|&0|mail163|lst_d9c@
secu_info=1
mail_entry_sess=7d3b347288dfc56a73f86b219b708ae5f9e8fc0a3ebabdab4b2bd8ae9fbbc022b67dc25b2e4cfa82fe21a9069a0b8260a5142bfc7a66a571d66e8ff93eb8d061f7eb08468dc9ed35013338fcffb0d0fe755f11b610b01a02fd50e721b7fee4d151502a0f2f13775d16bb84eb57203ce7108f2e7ba4c92bc5c5396501dc925d9117646a93c74cc141a0ef68c2ac79557ce9d953ba01892e6c0efa6fd9c1d6bca129b718743b592b696dc7fa070f29d0a187ead7ba3fe2d660765d1f0a6075490e
locale=
Coremail.sid=JBotLILIiJUXeLousXIIzvphyyqrIzxb
mail_style=js6
mail_uid=lst_d9c@
mail_host=
_ntes_nnid=21533f97b25070a31c249f59514ad20c,1492592485123
_ntes_nuid=21533f97b25070a31c249f59514ad20c
MailMasterPopupTips=1492592485755
★ 所有的Cookies中,只有_ntes_nnid 和 _ntes_nuid应该是JavaScript加密得到的。
import re
import requests
# 登录
mail = requests.Session()
login_headers = {
'Host': '',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/0101 Firefox/52.0',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language': 'zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3',
'Accept-Encoding': 'gzip, deflate, br',
'Referer': '/',
'Connection': 'keep-alive',
'Upgrade-Insecure-Requests': '1'
}
login_payload = {
'username': 'lst_d9c@',
'url2': '/errorpage/error163.htm',
'savalogin': '0',
'password': 'kuli401'
}
login_http = mail.post('/entry/cgi/ntesdoor?funcid=loginone&language=-1&passtype=1&iframe=1&product=mail163&from=web&df=email163&race=-2_39_-2_hz&module=&uid=lst_d9c@&style=-1&net=c&skinid=null', headers=login_headers, data=login_payload)
sid = re.search(r'(?<=sid=).+(?=&df=email163)', login_http.text).group(0)
#收信
receiving_headers = {
'Host': '',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/0101 Firefox/52.0',
'Accept': 'text/javascript',
'Accept-Language': 'zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3',
'Accept-Encoding': 'gzip, deflate',
'Content-Type': 'application/x-www-form-urlencoded',
'Referer': '/js6/main.jsp?sid=' + sid + '&df=email163',
'Content-Length': '539',
'Connection': 'keep-alive'
}
receiving_payload = {
'var': '<?xml version="1.0"?>1datetrue200falsetoptruetrue'
}
receiving_http = mail.post('/js6/s?sid=' + sid + '&func=mbox:listMessages&LeftNavfolder1Click=1&mbox_folder_enter=1', headers=receiving_headers, data=receiving_payload)
mid = re.search(r'(?<=\'id\':\')\S+(?=\',)', receiving_http.text).group(0)
#看信
read_headers = {
'Host': '',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/0101 Firefox/52.0',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language': 'zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3',
'Accept-Encoding': 'gzip, deflate',
'Referer': '/js6/main.jsp?sid=' + sid + '&df=email163',
'Connection': 'keep-alive',
'Upgrade-Insecure-Requests': '1'
}
read_http = mail.get('/js6/read/readhtml.jsp?mid=' + mid + '&font=15&color=064977', headers=read_headers)
print(sid)
print(mid)
print(read_http.text)