Selenium WebDriver-打开3个网址截图,文件夹用年月日命名,图片用当前时分秒命名

import os
import os.path
import time
from selenium import webdriver
urls=["http://www.baidu.com 

","http://www.sogou.com 

","http://cn.bing.com 

"]

dir_name=time.strftime("%Y-%m-%d",time.localtime())
if not os.path.exists("e:\"+dir_name):
    os.mkdir("e:\"+dir_name)
driver = webdriver.Ie 

(executable_path = "e:\IEDriverServer")
os.chdir("e:\"+dir_name)
for url in urls:
    driver.get(url)
    driver.get_screenshot_as_file(time.strftime("%H-%M-%S",time.localtime())+".png")
原文地址:https://www.cnblogs.com/qingqing-919/p/8709372.html