Mask jsoup as a Browser when downloading html
is it possible to mask
Jsoup.connect("http://xyz.com").get().html();
as a browser call to the website?
I try to build a wallpaper download tool and experiencing problems when downloading the page form the server.
If I downlo开发者_运维问答ad the page, say with Firefox, uploading this to a server of mine it is downloaded properly...
I figured it must be some browser based script prevention which doesn't let you parse the page automatically...
Try setting the User-Agent
header on the request. Ex:
String ua = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.122 Safari/534.30";
Jsoup.connect("http://example.com").userAgent(ua).get().html();
精彩评论