我是python的新手,正在使用webdriver构建一个scraper。我正在尝试从一个网站截图。它可以很好地截图,但保存在根文件夹中。我的代码在下面
print ("step is === "+str(scrollStep))
for i in range(1, max_sreenshots):
driver.save_screenshot("./screenshot_"+str(i)+".png")
driver.execute_script("window.scrollTo("+str(scrollStart)+", "+str(scrollEnd)+");")
scrollStart = scrollStart + scrollStep
scrollEnd = scrollEnd + scrollStep
如您所见,它只创建文件。我要它按日期保存在文件夹里。我怎么才能做到呢。 谢谢你
您希望将数据保存在何处?根目录/savedir?在任何情况下,将屏幕截图保存在根文件夹中的原因是代码第三行中的“./”。您可以尝试指定整个路径:
^{pr2}$time.strftime
还提供小时、分钟和秒,以备您需要:相关问题 更多 >
编程相关推荐