登陆邮箱 爬取邮件
发布时间:2020-12-17 17:13:01 所属栏目:Python 来源:网络整理
导读:今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 import urllib.parse,urllib.request,http.cookiejarimport redef doLogin(url,postData): postData = urllib.parse.urlencode(postData) postData =
以下代码由PHP站长网 52php.cn收集自互联网 现在PHP站长网小编把它分享给大家,仅供参考 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("登陆成功") 以上内容由PHP站长网【52php.cn】收集整理供大家参考研究 如果以上内容对您有帮助,欢迎收藏、点赞、推荐、分享。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |