国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

Python模擬登錄驗(yàn)證碼(代碼簡(jiǎn)單)

2019-11-25 16:56:48
字體:
供稿:網(wǎng)友

廢話不多說了,直接給大家貼代碼了。

import urllibimport urllib2import cookielibdef 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'''passdef login(coo):loginUrl = 'http://jwxt.wust.edu.cn/whkjdx/Logon.do?method=logon'data = {'USERNAME':'*****', 'PASSWORD':'*****', 'RANDOMCODE':coo}#encode the postDatapostData = 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 cookierequest = urllib2.Request(loginUrl, postData, headers = header)#post datacontent = opener.open(request)#get html filemainUrl = '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)

以上代碼大家看起來很容易吧,有不明白的地方歡迎留言,我會(huì)在第一時(shí)間和大家取得聯(lián)系的。在此武林網(wǎng)小編祝大家新年快樂。

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 邮箱| 汤阴县| 马龙县| 广东省| 盐亭县| 遂昌县| 资兴市| 台南市| 旌德县| 乡城县| 阿坝县| 内江市| 抚远县| 东丰县| 龙井市| 广德县| 遵化市| 县级市| 邢台县| 佛山市| 桑日县| 安庆市| 大同市| 上蔡县| 广宁县| 永寿县| 日喀则市| 石河子市| 余姚市| 黄梅县| 中阳县| 三河市| 齐齐哈尔市| 西乌珠穆沁旗| 龙胜| 二连浩特市| 天水市| 敦化市| 北安市| 杂多县| 通州区|