为每个发出的请求清除 Firefox 中的会话(Watir 问题)
我正在开发一个屏幕抓取机器人,它使用 Watir (ruby) 来抓取特定的网络搜索。 使用 Watir 是因为搜索结果以页面形式提供,只能通过 AJAX 请求获得。
我现在的问题是,要执行新的搜索,必须关闭浏览器才能清除搜索会话 - 否则初始搜索会否决 GET 参数中的更改。
是否可以强制 Firefox 清除每个请求的会话?
另外,有人有通过 Watir 解决此类问题的经验吗?
I'm developing a screen scraping robot that uses Watir (ruby) to crawl specific web searches.
Watir is used as the search results are delivered in pages, only available via AJAX requests.
My issue is now that to perform a new search, the browser has to be shut down in order for the search session to be cleared - otherwise the initial search overrule the change in the GET parameters.
Is it somehow possible to force Firefox to clear sessions on every request made?
Additionally, does anyone have experience solving these kind of issues via Watir?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果会话是通过 Firefox 浏览器中的 cookie 维护的,那么这是可能的。
您只需在启动之前从 Firefox Cookie 存储库中删除 Cookie。
Firefox 将其 cookie 存储在(在我的 ubuntu 和 mac 中)
或
(在 Firefox 3 之前,它是 cookies.txt 而不是 sqlite)
如果您可以截断 sqlite(或 txt),那么 cookie 将不再存在。
当您运行 Watir 时,您很可能正在使用 ruby。因此,如果您可以在 Watir::Browser.new 语句之前通过 system 或 %x[] (或通过 sqlite gem/lib 的兼容命令)运行这些命令,希望您能完成。
If the session is maintained via cookies in your firefox browser then it's possible.
All you have to remove the cookies from your firefox cookies repository before it starts.
Firefox stores its cookies at (as of in my ubuntu and mac)
or
(prior Firefox 3 it was cookies.txt instead sqlite)
If you can truncate the sqlite (or the txt) then the cookies will no longer be there.
As you are running Watir you are most probably using ruby. So, if you can run these commands through system or %x[] (or compatible commands through sqlite gem/lib) before Watir::Browser.new statement, hopefully you'll be done.
如果您想使用 Watir,您可以按照 http://watirwebdriver.com/ 中的说明修改配置文件。默认情况下,大多数浏览器似乎都会为每个新实例获取自己的配置文件。
If you want to use Watir, you can mess with profiles as described at http://watirwebdriver.com/. Most browsers seem to get their own profile for each new instance by default.