实际使用过程中,截图一般的使用场景:全屏截图、区域截图(截取指定的区域)
场景一、全屏截图
直接使用selenium的get_screenshot_as_file就可以实现
# -*- coding:utf-8 -*-
from selenium import webdriver
from time import sleep
import time
# 时间格式进行格式化
def time_format():
current_time = time.strftime('%Y%m%d%H%M%S', time.localtime(time.time()))
return current_time
driver = webdriver.Chrome()
driver.get('http://www.baidu.com/')
driver.get_screenshot_as_file("截图\"+time_format()+".png")
sleep(2)
driver.quit()
实现思路:
最后
以上就是俊逸水壶最近收集整理的关于Python+Selenium截图的全部内容,更多相关Python+Selenium截图内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复