开发者

How do you set javascript as enabled when using DefaultHttpClient?

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 javascri开发者_如何学编程pt 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.


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.


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.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜