HttpClient 抛出 403
尝试使用 apache HttpClient 访问 http://forum.worldoftanks.eu/index.php?app=members
但一直收到 403。有人可以帮忙吗? 一直在摆弄这件作品作为起点:
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpRequestBase method = new HttpGet(theUrl);
String s = httpClient.execute(method, new BasicResponseHandler());
System.out.println(s);
httpClient.getConnectionManager().shutdown();
trying to access http://forum.worldoftanks.eu/index.php?app=members
using apache HttpClient but keep getting 403. Can anyone help out?
Been fiddling with this piece as a starting point:
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpRequestBase method = new HttpGet(theUrl);
String s = httpClient.execute(method, new BasicResponseHandler());
System.out.println(s);
httpClient.getConnectionManager().shutdown();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这与 HttpClient 无关。我尝试过这个
但没有运气。
但我可以在浏览器中点击它。当未发送适当的浏览器标头时,可能有一些服务器逻辑返回 403。我的下一步是使用 FireBug 并尝试在浏览器发出请求时复制该请求。
另外,尝试捕获异常
I don't think this is related to HttpClient. I tried this
with no luck.
Yet I can hit it in the browser. It might be that there is some server logic returning 403s when an appropriate browser headers aren't sent. My next step would be to use FireBug and try to replicate the request as your browser makes it.
Also, try catching the exceptino