是否可以创建网页列表并使用python循环脚本打开此列表? 我尝试这样的事情,但在第一次网站失败后,selenium说:
selenium.common.exceptions.WebDriverException: Message: u'Session [1e42078b-f999-4a16-9b36-0c7281c95d44] was terminated due to CLIENT_STOPPED_SESSION' ; Stacktrace:
这是我的小脚本
from selenium import webdriver
fox = webdriver.Remote(desired_capabilities={
"browserName": "phantomjs",
"platform": "LINUX",
})
sites = ['google.com', 'yahoo.com']
for s in sites:
adrs = "http://" + str(s)
fox.get(adrs)
snap = s.split('.')[0]
fox.save_screenshot(snap +'.png')
fox.quit()
答案 0 :(得分:2)
fox.quit()
调用不应该在循环中发生,应该在以下后调用:
for s in sites:
adrs = "http://" + str(s)
fox.get(adrs)
snap = s.split('.')[0]
fox.save_screenshot(snap +'.png')
fox.quit()