显示图片两种方法

2020-07-14  本文已影响0人  sen_coder
截图
img = browser.find_element_by_xpath('//img[@onclick!=""]')
browser.save_screenshot('pictures.png')  # 全屏截图
page_snap_obj = Image.open('pictures.png')
sleep(1)
location = img.location
size = img.size  # 获取验证码的大小参数
left = location['x']
top = location['y']
right = left + size['width']
bottom = top + size['height']
image_obj = page_snap_obj.crop((left, top, right, bottom))  
image_obj.show()
a= input("请输入验证码:")
password = browser.find_element_by_name('code')
password.send_keys(a)

request.get
capt_raw = requests.get(CAPT_URL)
f = BytesIO(capt_raw.content)
  # 将验证码转换为Image对象
capt = Image.open(f)
capt.show()
上一篇 下一篇

猜你喜欢

热点阅读