Python自动登录126邮箱的方法
作者:Sephiroth 时间:2022-11-19 05:01:17
本文实例讲述了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,登录,邮箱
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
opencv实现车牌识别
2023-08-10 01:59:38
Python采集C站高校信息实战示例
2023-11-16 12:01:56
在python tkinter中Canvas实现进度条显示的方法
2023-06-04 18:12:56
![](https://img.aspxhome.com/file/2023/3/117373_0s.jpg)
python绘制散点图和折线图的方法
2021-08-24 04:27:56
![](https://img.aspxhome.com/file/2023/4/93624_0s.jpg)
python os模块介绍
2021-11-06 20:53:16
![](https://img.aspxhome.com/file/2023/5/133325_0s.png)
Python实现栈和队列的简单操作方法示例
2023-09-28 19:07:51
![](https://img.aspxhome.com/file/2023/0/111870_0s.png)
Python利用正则表达式匹配并截取指定子串及去重的方法
2021-05-07 00:37:20
用ReactJS和Python的Flask框架编写留言板的代码示例
2021-09-29 07:33:14
Python redis模块的使用教程指南
2021-03-22 12:08:02
Python pyecharts实时画图自定义可视化经纬度热力图
2023-12-24 10:14:21
![](https://img.aspxhome.com/file/2023/8/110478_0s.png)
python通过elixir包操作mysql数据库实例代码
2024-01-26 04:12:16
![](https://img.aspxhome.com/file/2023/2/92322_0s.png)
操作Windows注册表的简单的Python程序制作教程
2023-01-04 00:17:40
原生js+css调节音量滑块
2024-04-29 13:17:52
![](https://img.aspxhome.com/file/2023/8/132758_0s.gif)
Python drop方法删除列之inplace参数实例
2023-07-23 23:26:49
vue使用Element el-upload 组件踩坑记
2023-07-02 16:32:17
![](https://img.aspxhome.com/file/2023/0/139700_0s.png)
mysql登录报错提示:ERROR 1045 (28000)的解决方法
2024-01-24 04:54:01
ASP+FSO+框架实现ASP生成htm并分页的方法(批量)
2009-03-09 18:26:00
sqlserver清空service broker中的队列的语句分享
2011-09-30 11:33:35
关于SQL Server数据库中转储设备分析
2009-01-21 14:55:00
Python测试Kafka集群(pykafka)实例
2023-05-05 20:57:56