#以时间年月日创建文件夹,并以时分秒保存截图图片
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 = "g:\\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")


本文介绍了一种使用Python的Selenium库和时间库实现定时创建日期文件夹并按时间戳保存网页截图的方法。通过设置URL列表,可以批量抓取多个网站的即时界面快照,适用于网站监控或界面变化记录。
74

被折叠的 条评论
为什么被折叠?



