问题描述
我目前可以正确运行我的代码和脚本,同时能够获取所有我需要抓取的数据。我的目标是让脚本运行几个小时,并使用网络驱动程序每分钟刷新一次,以刮取单个页面。但是,此过程仅在前15分钟有效。
我通过运行以下命令在一个was EC2远程实例上运行它:
java -jar selenium-server-standalone-3.141.59.jar -port 4444 -sessionTimeout 57868143 &
python3 /home/ec2-user/scraper/football_live.py;
启动selenium服务器(运行时间超过15分钟),然后启动脚本。
在我的脚本中,我有:
data,n_games = football_data(driver)
insert_data(cur,conn,data)
time.sleep(60)
driver.refresh()
在while循环内,它将运行很长时间。
这是我的网络驱动程序代码:
chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandBox')
time.sleep(5)
driver = webdriver.Remote("http://localhost:4444/wd/hub",options=chrome_options,desired_capabilities=DesiredCapabilities.CHROME)
Here是我发现的唯一与我尝试做的事情接近的事情,但并没有那么大的帮助。
如果没有办法通过selenium延长webdriver的持续时间,我也正在考虑仅尝试在脚本中运行15分钟循环。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)