通过 Apache 的 HttpClient 访问 iframe 页面

发布于 2024-11-15 20:01:58 字数 248 浏览 3 评论 0原文

我一直致力于解析一个网站,但当我需要解析的主要页面之一只能在 iframe 中找到时,我遇到了问题。

我可以看到父页面的 URL,并多次尝试通过 HttpGet 访问它(当然是在登录之后并且能够访问任何其他帐户特定页面),但失败了。事实上,我给出的页面是用户根本没有登录时会看到的页面。然而,在我的 HttpGet 执行此 iframe 父级的上方行中,我显示我是通过 cookie 登录的。

简而言之,如何访问 iframe 父页面并保持登录状态?

I've been working on parsing a website but am running into problems when one of the major pages I need to parse can only be found in an iframe.

I can see the URL to the parent page and have attempted many times to visit it through HttpGet (after being logged in of course and being able to visit any other account specific page), but it fails. In fact, the page that I am given is the page a user would get if they were not logged in at all. Yet in the line above my HttpGet execute for this iframe parent I show that I am logged in via cookies.

In short, how can I access an iframe parent page and stay logged in?

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

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

发布评论

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

评论(1

无力看清 2024-11-22 20:01:58

我相信这是因为您记录的 cookie 与 iframe 发出的第二个请求没有关联,因此将您重定向到登录页面。

您应该能够通过单独请求 iframe 并将其传递给您记录的 cookie 来查看该 iframe。例如

HttpURLConnection.setRequestProperty("Cookie", "JSESSIONID=" + sessionId);

I believe this is due to the fact that your logged cookie is not associated with the second request made by the iframe and thus redirecting you to the login page.

You should be able to view the iframe by requesting it seperately and passing it your logged cookie. eg

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