I want to parse an external webpage with Jsoup in an android app. Actually I manage to do it except it’s the mobile version. So… I tried to set User Agent to something else than a “mobile” one.
The problem is that with .userAgent() option and .header(), IOException returns 403 error.
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();
And the Http Response :
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
Is there something here preventing the connection ?
Thanks
Your request is most likely getting blocked by your mobile data carrier (they only allow mobile User-Agents).