美文网首页
显示图片两种方法

显示图片两种方法

作者: sen_coder | 来源:发表于2020-07-14 18:10 被阅读0次
截图
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()

相关文章

网友评论

      本文标题:显示图片两种方法

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