# 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')
网友评论