此包用于剪裁selenium webdriver的html元素的图像
Selenium-Screenshot的Python项目详细描述
slenium屏幕截图:
selenium屏幕截图用于使用selenium webdriver剪裁html元素
安装:
pip install Selenium-Screenshot
python 3支持此包。*
使用方法:
整页截图:
fromScreenshotimportScreenshot_Clippingfromseleniumimportwebdriverob=Screenshot_Clipping.Screenshot()driver=webdriver.Chrome()url="https://github.com/sam4u3/Selenium_Screenshot/tree/master/test"driver.get(url)img_url=ob.full_Screenshot(driver,save_path=r'.',image_name='Myimage.png')print(img_url)driver.close()driver.quit()
用于HTML元素剪辑:
fromScreenshotimportScreenshot_Clippingfromseleniumimportwebdriverob=Screenshot_Clipping.Screenshot()driver=webdriver.Chrome()url="https://github.com/sam4u3/Selenium_Screenshot/blob/master/Screenshot/Screenshot_Clipping.py"driver.get(url)element=driver.find_element_by_class_name('signup-prompt')img_url=ob.get_element(driver,element,r'.')print(img_url)driver.close()driver.quit()
用于隐藏元素的HTML元素剪辑:
fromScreenshotimportScreenshot_Clippingfromseleniumimportwebdriverob=Screenshot_Clipping.Screenshot()driver=webdriver.Chrome()url="https://github.com/sam4u3"driver.get(url)Hide_elements=['class=avatar width-full height-full avatar-before-user-status']# Use full class nameimg_url=ob.full_Screenshot(driver,save_path=r'.',elements=Hide_elements,image_name='Myimage.png')print(img_url)driver.close()driver.quit()
联系方式:
Email: sayarmendis26@gmail.com