本文实例讲述了Python实现模拟登录网易邮箱的方法。分享给大家供大家参考,具体如下:
#coding:utf-8import urllib2,urllibimport cookielibfrom bs4 import BeautifulSoup#设置代理IPproxy_support = urllib2.ProxyHandler({'http':'120.197.234.164:80'})#设置cookiecookie_support = urllib2.HTTPCookieProcessor(cookielib.LWPCookieJar())opener = urllib2.build_opener(proxy_support,cookie_support,urllib2.HTTPHandler)urllib2.install_opener(opener)#开始的URL#hosturl = "http:///'}#生成HTTP请求req =urllib2.Request( url = posturl, data = postdata, headers = headers)print reqpage = urllib2.urlopen(req).read()print pagelistvalue = page.split(";")url = listvalue[0].split("op.location.href = ")[1]href = url[1:-1]print hrefsoup = BeautifulSoup(urllib2.urlopen(href))print soup.title推荐一篇不错的文章:
更多关于Python相关内容可查看本站专题:《Python Socket编程技巧总结》、《Python数据结构与算法教程》、《Python函数使用技巧总结》、《Python字符串操作技巧汇总》、《Python入门与进阶经典教程》及《Python文件与目录操作技巧汇总》
希望本文所述对大家Python程序设计有所帮助。