selenium访问百度 然后获取百度logo的截图

mac2022-06-30  25

#!/usr/bin/env python # encoding: utf-8 import time from selenium import webdriver from PIL import Image from io import BytesIO driver=webdriver.Chrome() driver.get("http://www.baidu.com/") img=driver.find_element_by_xpath("//div/img") location=img.location size=img.size x=location["x"] y=location["y"] height=size["height"] wid=size["width"] im=Image.open(BytesIO(driver.get_screenshot_as_png())) im.show() box=(x,y,x+wid,y+height) #这四个参数表示要截取的坐标 左上角的x,y右下角的x,y captcha=im.crop(box) #截取上面指定的区域 captcha.show()

  

转载于:https://www.cnblogs.com/c-x-a/p/8962500.html

最新回复(0)