【问题标题】:Jsoup 403 error and Android user agentJsoup 403 错误和 Android 用户代理
【发布时间】:2011-12-12 04:51:01
【问题描述】:

我想在 Android 应用程序中使用 Jsoup 解析外部网页。实际上我设法做到了,除了它是移动版本。所以...我试图将用户代理设置为“移动”之外的其他东西。

问题是使用 .userAgent() 选项和 .header(),IOException 返回 403 错误。

Document doc = Jsoup.connect(url).header("User-Agent", "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9.2.2) Gecko/20100316 Firefox/3.6.2").get();

还有 Http 响应:

Date    Mon, 12 Dec 2011 04:08:38 GMT
Content-Type    text/html; charset=utf-8
Transfer-Encoding   chunked
Connection  keep-alive
P3P CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"
Cache-Control   no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Expires Mon, 12 Dec 2011 00:00:00 GMT
Last-Modified   Mon, 12 Dec 2011 04:08:38 GMT
Pragma  no-cache
X-Content-Type-Options  nosniff
X-XSS-Protection    1; mode=block
Content-Encoding    gzip

这里有什么东西阻止了连接吗?

谢谢

【问题讨论】:

    标签: android httpresponse user-agent jsoup


    【解决方案1】:

    您的请求很可能被您的移动数据运营商阻止(他们只允许移动用户代理)。

    【讨论】:

    • 前段时间我收到了他们的确认。同时,我切换到另一个具有合理使用选项的数据载体。它完美地工作。这显然不是正确的做法……我认为最好的办法是获得一个专门用于移动设备的网络服务。感谢您的回复!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-11-18
    • 2016-07-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-01
    • 2016-12-26
    相关资源
    最近更新 更多