1. 程式人生 > >Python3.x:獲取登錄界面校驗碼圖片

Python3.x:獲取登錄界面校驗碼圖片

urn and code 實例 return align ace get pan

Python3.x:獲取登錄界面校驗碼圖片

實例代碼:

# python3
# author lizm
# datetime 2018-06-01 18:00:00
# -*- coding: utf-8 -*-
‘‘‘
    oa:http://******/login/loginpage.do
‘‘‘

from splinter.browser import Browser
from time import sleep
# traceback模塊被用來跟蹤異常返回信息
import traceback
import urllib
import urllib.request

#獲取校驗碼圖片
def getImage(imgUrl):
    request 
= urllib.request.Request(imgUrl) response = urllib.request.urlopen(request) get_img = response.read() with open(001.jpg,wb) as fp: fp.write(get_img) print(校驗碼下載完成) return if __name__ == "__main__": getImage(http://******/views/randomImage.jsp?Rand=5964.904004367221
)

Python3.x:獲取登錄界面校驗碼圖片