日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python验证码登录代码_Python模拟登录验证码(代码简单)

發布時間:2023/12/20 python 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python验证码登录代码_Python模拟登录验证码(代码简单) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

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

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)

以上代碼大家看起來很容易吧,有不明白的地方歡迎留言,我會在第一時間和大家取得聯系的。在此萬仟網小編祝大家新年快樂。

如您對本文有疑問或者有任何想說的,請點擊進行留言回復,萬千網友為您解惑!

總結

以上是生活随笔為你收集整理的python验证码登录代码_Python模拟登录验证码(代码简单)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。