如何在 Firefox 和 Perl 之间自动化和共享会话?

发布于 2024-08-14 06:27:30 字数 192 浏览 11 评论 0原文

是否可以在 Perl 中执行部分 Web 流程,然后将会话的其余部分传输到 Firefox?
我需要重试(使用 Perl)登录到一个网站,该网站时不时地返回 500,然后在成功登录后,将经过身份验证的会话传输到 Firefox,从那里我可以继续正常浏览。这可能吗?
如果这是可能的,我该怎么做?您能给我指出一些关于如何传输 cookie/会话等的资源吗?

Is it possible to do part of a web flow in Perl and then transfer the rest of the session to Firefox?
I need to retry(with Perl) logging in to a website which returns 500 every now and then on a successful login, transfer the authenticated session to Firefox, from where I can continue my normal browsing. Is this possible?
If this is possible, how do I do it? Can you point me to some resources on how can transfer the cookie/session, etc ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

安静被遗忘 2024-08-21 06:27:30

对我来说,似乎在 Firefox 内部完成所有事情并从外部进行控制更有意义。 MozRepl(FF 扩展)和 MozRepl(Perl 模块)可能会帮助您实现这一目标。

To me, it seems that it makes more sense to do everything from within Firefox ... and control that from the outside. MozRepl (the FF extension) and MozRepl (the Perl module) may help you in getting there.

情感失落者 2024-08-21 06:27:30

棘手。您将无法让您的服务器登录到第 3 方服务,然后仅向您的用户提供会话 cookie,并将其重定向到第 3 方应用程序。这将不起作用,因为 cookie 是特定于域的,并且域无法访问来自另一个域或由另一个域设置的 cookie。

因此,您的服务需要充当第三方服务的接口,因此您需要在服务器上维护用户会话。此用户会话会跟踪您的用户,将登录第三方服务,并在适当的时候向第三方服务发出请求。您服务器上的会话将是该第 3 方服务的 http 客户端,因此它需要能够正确处理 cookie - 即模仿浏览器。

在设置和维护用户会话方面,有许多 CPAN 模块可以帮助您完成此任务。

有关在 Perl 中管理用户会话的详细信息,请参阅 https://web.archive.org/web/1/http://articles.techrepublic%2ecom%2ecom/5100-10878_11-1044683.html

编辑:某些网络服务可以当客户端拒绝 cookie 时,通过将会话 ID 注入 URL 来管理用户会话。如果您的第 3 方服务可以执行此操作,您可能只需提供登录响应 URL 作为对您的用户的重定向。但是,如果会话绑定到 IP,这将会中断。

Tricky. You will not be able to have your server log in to the 3rd party service, and then just serve up the session cookie to your user, and redirect him to the 3rd party app. This will not work because cookies are domain specific, and domains cannot access cookies from or set by another domain.

So your service will need to act as an interface to the third party service, and as such you will need to maintain a user session on your server. This user session keeps track of your user, will log in to third party service, and will make requests to the 3rd party service when appropriate. The session on your server will be an http client for this 3rd party service, so it will need to be able to handle cookies correctly - ie mimic a browser.

In terms of setting up and maintaining user sessions, there will be a number of CPAN modules to help you with this.

For more info on managing user sessions in Perl, see https://web.archive.org/web/1/http://articles.techrepublic%2ecom%2ecom/5100-10878_11-1044683.html

Edit: some web services can manage user sessions by injecting a session id into the URL when the client refuses cookies. If your 3rd party service will do this, you could maybe just serve up the login response URL as a redirect to your user. However, this will break if sessions are bound to an IP.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文