selenium截取验证码图片
生活随笔
收集整理的這篇文章主要介紹了
selenium截取验证码图片
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
# 截取驗證碼圖片
from PIL import Image
driver.save_screenshot('bdbutton.png')
element = driver.find_element_by_xpath('//*[@id="nc_1_clickCaptcha"]/div[2]/img') #找到驗證碼圖片
print(element.location) # 打印元素坐標
print(element.size) # 打印元素大小
left = element.location['x']
top = element.location['y']
right = element.location['x'] + element.size['width']
bottom = element.location['y'] + element.size['height']im = Image.open('bdbutton.png')
im = im.crop((left, top, right, bottom))
im.save('bdbutton.png') # 將得到的圖片保存在本地
?
轉載于:https://www.cnblogs.com/gaoyukun/p/9719615.html
總結
以上是生活随笔為你收集整理的selenium截取验证码图片的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 01-智能运维简介
- 下一篇: Liferay 7:Liferay内部博