使用 DefaultHttpClient 时如何将 javascript 设置为启用?

发布于 2024-10-01 08:37:55 字数 430 浏览 1 评论 0原文

我正在尝试使用 DefaultHttpClient 登录 xbox.com。我意识到如果不访问 http://login.live.com 就无法登录,所以我打算提交该页面上的表单,然后在对 xbox.com 的任何请求中使用 cookie。

问题是使用 DefaultHttpClient 从 live.com 请求任何内容都会返回以下消息。

Windows Live ID 需要 JavaScript 才能登录。此 Web 浏览器不支持 JavaScript,或者脚本被阻止。

我如何告诉 DefaultHttpClient 告诉服务器 javascript 可以使用?我尝试查看默认选项并将其添加为参数对象,但我看不到我必须做什么。

Im trying to use DefaultHttpClient to log into xbox.com. I realize that you cant be logged in without visiting http://login.live.com, so I was going to submit to the form on that page and then use the cookies in any requests to xbox.com.

The problem is that requesting anything from live.com using DefaultHttpClient returns the followings message.

Windows Live ID requires JavaScript to sign in. This web browser either does not support JavaScript, or scripts are being blocked.

How do I tell DefaultHttpClient to tell the server that javascript is available for use? I tried looking in the default options and also adding it as a parameter object but I cant see what I've got to do.

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

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

发布评论

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

评论(3

画中仙 2024-10-08 08:37:55

发生这种情况的原因是,这行 HTML 是从 live: 中解析的,

<noscript><meta http-equiv="Refresh" content="0; URL=http://login.live.com/jsDisabled.srf?mkt=EN-US&lc=1033"/>Windows Live ID requires JavaScript to sign in. This web browser either does not support JavaScript, or scripts are being blocked.<br /><br />To find out whether your browser supports JavaScript, or to allow scripts, see the browser's online help.</noscript>

如果您的客户端没有启用 javascript,则该行用于重定向您(因此将解析 标记。)

您可以尝试使用不太智能的 HTTP 库,它不解析内容,而只是进行传输并将解析留给您。

The reason this is happening is that this line of HTML is getting parsed from live:

<noscript><meta http-equiv="Refresh" content="0; URL=http://login.live.com/jsDisabled.srf?mkt=EN-US&lc=1033"/>Windows Live ID requires JavaScript to sign in. This web browser either does not support JavaScript, or scripts are being blocked.<br /><br />To find out whether your browser supports JavaScript, or to allow scripts, see the browser's online help.</noscript>

Which is used to redirect you if your client does not have javascript enabled (and therefore will parse <noscript> tags.)

You could try to use a less intelligent HTTP library which does no parsing of the content, but which instead simply does the transport and leaves the parsing to you.

彼岸花似海 2024-10-08 08:37:55

使用 Wireshark 来跟踪使用浏览器和程序的通信,并查找差异。很难确切地说 live.com/xbox.com 正在寻找什么,但可能有一些 AJAX-y 代码用于获取实际内容。

Use Wireshark to trace the communication using both a browser and your program, and look for the differences. It's hard to say what, exactly, live.com/xbox.com are looking for, but there is likely some AJAX-y code used to get the actual content.

无妨# 2024-10-08 08:37:55

Windows Live ID requires JavaScript to sign in. This web browser either does not support JavaScript, or scripts are being blocked.

To find out whether your browser supports JavaScript, or to allow scripts, see the browser's online help.

Windows Live ID requires JavaScript to sign in. This web browser either does not support JavaScript, or scripts are being blocked.

To find out whether your browser supports JavaScript, or to allow scripts, see the browser's online help.

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