是否有可能为Jsoup连接设置Accept-Language参数。 我试过了:
Jsoup.connection(url).userAgent("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:21.0) Gecko/20100101 Firefox/21.0").get();
Jsoup.connection(url).userAgent("Mozilla/5.0 (Windows; U; WindowsNT 5.1; en-US; rv1.8.1.6) Gecko/20070725 Firefox/2.0.0.6").get();
但不起作用......
答案 0 :(得分:12)
您必须将Header
添加到Connection
,如下所述
Jsoup.connection(url)
.userAgent("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:21.0) Gecko/20100101 Firefox/21.0")
.header("Accept-Language", "en")
.header("Accept-Encoding","gzip,deflate,sdch");//can add as many as you like
.get();