Python實(shí)現(xiàn)模擬登錄網(wǎng)易郵箱的方法示例
本文實(shí)例講述了Python實(shí)現(xiàn)模擬登錄網(wǎng)易郵箱的方法。分享給大家供大家參考,具體如下:
#coding:utf-8 import urllib2,urllib import cookielib from bs4 import BeautifulSoup #設(shè)置代理IP proxy_support = urllib2.ProxyHandler({'http':'120.197.234.164:80'}) #設(shè)置cookie cookie_support = urllib2.HTTPCookieProcessor(cookielib.LWPCookieJar()) opener = urllib2.build_opener(proxy_support,cookie_support,urllib2.HTTPHandler) urllib2.install_opener(opener) #開始的URL #hosturl = "http://www.renren.com" hosturl = "http://mail.163.com/" #接受表單數(shù)據(jù)的URL #posturl = "http://www.renren.com/ajaxLogin/login" posturl = "https://mail.163.com/entry/cgi/ntesdoor?df=mail163_letter&from=web&funcid=loginone&iframe=1&language=-1&passtype=1&product=mail163&net=e&style=-1&race=118_35_39_bj&uid=Thinkgamer@163.com" #發(fā)送表單數(shù)據(jù) postdata = urllib.urlencode( { "username":"xxxxxxxxxxx", "password":"xxxxxxxxxxxxxxx" } ) #設(shè)置表頭 headers = { #'User-Agent':'Mozilla/5.0 (Windows NT 6.3; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0/', #'Referer':'http://www.renren.com/' 'User-Agent':"Mozilla/5.0 (Windows NT 6.3; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0", 'Referer':'http://mail.163.com/' } #生成HTTP請(qǐng)求 req =urllib2.Request( url = posturl, data = postdata, headers = headers ) print req page = urllib2.urlopen(req).read() print page listvalue = page.split(";") url = listvalue[0].split("op.location.href = ")[1] href = url[1:-1] print href soup = BeautifulSoup(urllib2.urlopen(href)) print soup.title
推薦一篇不錯(cuò)的文章:http://www.dbjr.com.cn/article/90114.htm
更多關(guān)于Python相關(guān)內(nèi)容可查看本站專題:《Python Socket編程技巧總結(jié)》、《Python數(shù)據(jù)結(jié)構(gòu)與算法教程》、《Python函數(shù)使用技巧總結(jié)》、《Python字符串操作技巧匯總》、《Python入門與進(jìn)階經(jīng)典教程》及《Python文件與目錄操作技巧匯總》
希望本文所述對(duì)大家Python程序設(shè)計(jì)有所幫助。
相關(guān)文章
keras 自定義loss損失函數(shù),sample在loss上的加權(quán)和metric詳解
這篇文章主要介紹了keras 自定義loss損失函數(shù),sample在loss上的加權(quán)和metric詳解,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2020-05-05keras load model時(shí)出現(xiàn)Missing Layer錯(cuò)誤的解決方式
這篇文章主要介紹了keras load model時(shí)出現(xiàn)Missing Layer錯(cuò)誤的解決方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2020-06-06對(duì)于Python的Django框架使用的一些實(shí)用建議
這篇文章主要介紹了對(duì)于Python的Django框架使用的一些實(shí)用建議,包括一些優(yōu)秀模塊的介紹,要的朋友可以參考下2015-04-04python實(shí)現(xiàn)秒殺商品的微信自動(dòng)提醒功能(代碼詳解)
這篇文章主要介紹了python實(shí)現(xiàn)秒殺商品的微信自動(dòng)提醒功能,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-04-04OpenCV-Python實(shí)現(xiàn)圖像平滑處理操作
圖像平滑處理的噪聲取值主要有6種方法,本文主要介紹了這6種方法的具體使用并配置實(shí)例方法,具有一定的參考價(jià)值,感興趣的可以了解一下2021-06-06關(guān)于python之字典的嵌套,遞歸調(diào)用方法
今天小編就為大家分享一篇關(guān)于python之字典的嵌套,遞歸調(diào)用方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2019-01-01python 創(chuàng)建彈出式菜單的實(shí)現(xiàn)代碼
這篇文章主要介紹了python 創(chuàng)建彈出式菜單的實(shí)現(xiàn)代碼的相關(guān)資料,需要的朋友可以參考下2017-07-07