对于scrapy/selenium,有没有办法返回上一页? [英] For scrapy/selenium is there a way to go back to a previous page?

查看:28
本文介绍了对于scrapy/selenium,有没有办法返回上一页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我本质上有一个包含我的 javascript 搜索表单和按钮的 start_url,因此需要 selenium.我使用 selenium 在我的选择框对象中选择适当的项目,然后单击搜索按钮.在接下来的页面中,我做了一些爬虫魔术.但是,现在我想回到原来的 start_url 并填写一个不同的对象等,然后重复直到不再.

I essentially have a start_url that has my javascript search form and button, hence the need of selenium. I use selenium to select the appropriate items in my select box objects, and click the search button. The following page, I do some scrapy magic. However, now I want to go BACK to the original start_url and fill out a different object, etc. and repeat until no more.

从本质上讲,我尝试过进行 for 循环并尝试让浏览器返回到原始 response.url,但不知何故它崩溃了.我可能会尝试在顶部有一个重复的 start_url 列表,以便scrapy 解析,但我不确定这是否是最好的方法.在我的情况下我能做什么?

Essentially, I have tried making a for-loop and trying to get the browser to go back to the original response.url, but somehow it crashed. I may try having a duplicate list of start_url's on the top for scrapy to parse through, but I'm not sure if that is the best approach. What can I do in my situation?

推荐答案

这里的建议是使用 driver.back() : https://selenium-python.readthedocs.io/navigating.html#navigation-history-and-位置

这篇关于对于scrapy/selenium,有没有办法返回上一页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆