登陆邮箱 爬取邮件,登陆邮箱邮件,import urlli
文章由Byrx.net分享于2019-03-23 05:03:05
登陆邮箱 爬取邮件,登陆邮箱邮件,import urlli
import urllib.parse,urllib.request,http.cookiejarimport redef doLogin(url,postData): postData = urllib.parse.urlencode(postData) postData = postData.encode(encoding='UTF-8') header = {'User-Agent':'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)'} req = urllib.request.Request( url=url, data=postData, headers=header ) return urllib.request.urlopen(req).read().decode('UTF8')def setCookie(): cookie = http.cookiejar.CookieJar() cookieProc = urllib.request.HTTPCookieProcessor(cookie) opener = urllib.request.build_opener(cookieProc) urllib.request.install_opener(opener)url = "https://ssl.mail.163.com/entry/coremail/fcg/ntesdoor2?df=webmail163&from=web&funcid=loginone&iframe=1&language=-1&net=t&passtype=1&product=mail163&race=-2_-2_-2_db&style=-1&uid=xxxxxx"strLoginInfo ={"username":"xxxxxx", "password":"123456abc"}setCookie()resp = doLogin(url,strLoginInfo)m = re.search(r'href\s*=\s*"(.*)"',resp)loginUrl = ""if m: loginUrl = m.group(1)logResp = urllib.request.urlopen(loginUrl)html=logResp.read().decode('utf-8')if not html.find("收件箱") == -1: print("登陆成功")
相关内容
- 移动Web APP开发之实战美团外卖,app外卖,如需下述哪一
- python字典读取语言文件=号后的内容合并.py,python.py,"
- wifi 掉线自动重连,wifi掉线,#!/usr/bin/e
- python多线程多队列(BeautifulSoup网络爬虫),,程序大概
- 用Python多线程抓取并验证代理,python多线程抓取,因为工
- range()、xrange()函数实现,rangexrange,# -*- coding
- 列表去重,列表,#!/usr/bin/e
- linux终端播放音乐歌词同步显示,linux歌词同步,#!/usr/
- 封装的Mysql简易操作,封装Mysql简易操作,import pymys
- 批量将gbk文件转换成utf-8,gbk文件utf-8,#!/usr/bin/p
评论关闭