截图
1 # -*- coding:utf-8 -*- 2 """ 3 get_screenshot_as_file:截图 4 save_screenshot: 截图 5 """ 6 7 from selenium import webdriver 8 import datetime 9 10 driver = webdriver.Firefox() 11 12 driver.get('http://www.baidu.com') 13 14 #给图片名加上时间戳,确保不被重复 15 driver.get_screenshot_as_file(r'c:\%s.jpg' %datetime.datetime.now().strftime("%Y%m%d_%H%M%S_%f")[:-3]) 16 driver.save_screenshot(r'c:\1.jpg')