黑松山资源网 Design By www.paidiu.com
废话不多说了,直接给大家贴代码了。
import urllib import urllib2 import cookielib def getImg(picurl): ''' request for random_code picture and cookie ''' pic = opener.open(picurl).read() with open('./verifyImg.jpg','wb') as emptyPic: emptyPic.write(pic) def verifyImg(picpath): ''' TODO ''' pass def login(coo): loginUrl = 'http://jwxt.wust.edu.cn/whkjdx/Logon.do?method=logon' data = {'USERNAME':'*****', 'PASSWORD':'*****', 'RANDOMCODE':coo} #encode the postData postData = urllib.urlencode(data) user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)' header = {'User-Agent':user_agent,'Referer':'http://jwxt.wust.edu.cn/whkjdx/framework/main.jsp'} #generate a Request with url,postData headers and cookie request = urllib2.Request(loginUrl, postData, headers = header) #post data content = opener.open(request) #get html file mainUrl = 'http://jwxt.wust.edu.cn/whkjdx/framework/main.jsp' mainContent = opener.open(mainUrl).read() print mainContent if __name__ == '__main__': cookie = cookielib.CookieJar() handler = urllib2.HTTPCookieProcessor(cookie) opener = urllib2.build_opener(handler) picurl = 'http://jwxt.wust.edu.cn/whkjdx/verifycode.servlet' getImg(picurl) #verifyImg(picpath) randomCode = raw_input('Plz input teh randomcode:') login(randomCode)
以上代码大家看起来很容易吧,有不明白的地方欢迎留言,我会在第一时间和大家取得联系的。在此小编祝大家新年快乐。
黑松山资源网 Design By www.paidiu.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
黑松山资源网 Design By www.paidiu.com
暂无评论...
更新日志
2024年10月09日
2024年10月09日
- 碧蓝航线国庆金秋版本重磅上线 新玩法3D宿舍系统闪亮登场
- 自在西游自在服即将在10月1日开启 入驻即享豪礼满满
- 炉石传说最强术士卡组是哪个 术士最强天梯卡组推荐一览
- 炉石传说最强萨尔卡组是哪个 萨尔最强天梯卡组推荐一览
- 炉石传说最强潜行者卡组是哪个 潜行者最强天梯卡组推荐一览
- 银霞.1983-《爱迷惑我·我住小楼中》台湾复刻版[WAV+CUE]
- [雨果唱片]粤曲名家-《再折长亭柳》[WAV+CUE]
- 刘德华1998-你是我的女人[香港第二版][WAV]
- 压迫感谁最强?外媒评选恐怖游戏最佳女反派
- 还没正式发售:《寂静岭2:重制版》Steam玩家峰值近9000人
- 别搞政确了!超95%国外玩家反对强制包容性
- 《暗喻幻想:ReFantazio》试玩:ATLUS的自我挑战?
- 《憧憬成为魔法少女》第二季 反转魔法少女题材再掀热潮
- 海信AI电视E7N正式发布,引领AI画质新标杆
- 屠洪刚.2002-九九艳阳天【京文】【WAV+CUE】