登陆邮箱 爬取邮件
发布时间:2020-05-25 00:53:09 所属栏目:Python 来源:互联网
导读:登陆邮箱 爬取邮件
|
下面是脚本之家 jb51.cc 通过网络收集整理的代码片段。 脚本之家小编现在分享给大家,也给大家做个参考。 import urllib.parse,urllib.request,http.cookiejar
import re
def 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'hrefs*=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("登陆成功")
以上是脚本之家(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。 如果觉得脚本之家网站内容还不错,欢迎将脚本之家网站推荐给程序员好友。 (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
