Python自動登錄126郵箱的方法
更新時間:2015年07月10日 16:04:18 作者:Sephiroth
這篇文章主要介紹了Python自動登錄126郵箱的方法,涉及Python針對郵箱操作的相關(guān)技巧,具有一定參考借鑒價值,需要的朋友可以參考下
本文實例講述了Python自動登錄126郵箱的方法。分享給大家供大家參考。具體實現(xiàn)方法如下:
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程序設計有所幫助。
相關(guān)文章
一個簡單的python爬蟲程序 爬取豆瓣熱度Top100以內(nèi)的電影信息
這篇文章主要為大家詳細介紹了一個簡單的python爬蟲程序,爬取豆瓣熱度Top100以內(nèi)的電影信息,具有一定的參考價值,感興趣的小伙伴們可以參考一下2018-04-04Python實現(xiàn)PIL圖像處理庫繪制國際象棋棋盤
本文主要介紹了Python實現(xiàn)PIL圖像處理庫繪制國際象棋棋盤,文中通過示例代碼介紹的非常詳細,需要的朋友們下面隨著小編來一起學習學習吧2021-07-07