美文网首页
selenium获取验证码图片

selenium获取验证码图片

作者: 裴general | 来源:发表于2018-08-26 11:57 被阅读0次
# coding=utf-8
import time
from selenium import webdriver
from PIL import Image

driver = webdriver.Chrome()
driver.maximize_window()
driver.implicitly_wait(6)
driver.get("http://shuidi.cn/pcuser-register")
time.sleep(1)

driver.get_screenshot_as_file('pei.png')
imgelement = driver.find_element_by_xpath('/html/body/div[2]/div/div/div[3]/div[2]')  #定位验证码
location = imgelement.location
size = imgelement.size
print(location)
print(size)
driver.close()
rangle = (1022, 308, 1122, 348)
# rangle = (830, 388, 952, 440)
i = Image.open('pei.png')
frame4 = i.crop(rangle)
frame4.save('min.png')

相关文章

网友评论

      本文标题:selenium获取验证码图片

      本文链接:https://www.haomeiwen.com/subject/vyqoiftx.html