跳转到主内容
websoft网络软件专家 - 深耕网络技术,打造实用软件!

Python自动登录126邮箱的方法

本文实例讲述了 python 自动登录126邮箱的方法。分享给大家供大家参考。具体实现方法如下:
import sys, urllib2, urllib,cookielib import re cookie = cookielib.LWPCookieJar() opener=urllib2.build_opener(urllib2.HTTPCookieProcessor(cookie)) urllib2.install_opener(opener) url='http://entry.mail.126.com/cgi/login?hid=10010102&lightweight=1&language=0&style=11' user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)' headers = { 'User-Agent' : user_agent } values = {'bCookie' : '', 'domain' : '126.com', 'enter.x' : '登 录', 'language':'0', 'pass':'#####', 'style':'11', 'user':'guijia8427'} data = urllib.urlencode(values) req = urllib2.Request(url, data ,headers) response = urllib2.urlopen(req) the_page = response.read() sor= re.compile(r'sid=(.+)&funcid') s=sor.findall(the_page) url2='http://tg1a3.mail.126.com/coremail/fcg/ldapapp?funcid=mails&sid='+s[0]+'&fid=1' g=opener.open(url2) data2=g.read() file=open('126.html','w') file.write(data2) file.close()
希望本文所述对大家的Python程序设计有所帮助。 Python 3.14.3 微软官方的 Python 扩展,是 VS Code 安装量最高的扩展(209M+)。集成 IntelliSense(通过 Pylance)、调试(通过 Python Debugger)、代码检查、格式化、重构和单元测试等功能。支持 Jupyter Notebook、虚拟环境管理和多 Python 版本切换。 下载

相关文章