使用 DefaultHttpClient 时如何将 javascript 设置为启用?
我正在尝试使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
发生这种情况的原因是,这行 HTML 是从 live: 中解析的,
如果您的客户端没有启用 javascript,则该行用于重定向您(因此将解析
标记。)
您可以尝试使用不太智能的 HTTP 库,它不解析内容,而只是进行传输并将解析留给您。
The reason this is happening is that this line of HTML is getting parsed from live:
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.
使用 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.
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.