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")

 

posted @ 2018-04-03 16:37  小七Libra  阅读(295)  评论(0编辑  收藏  举报