本文介绍了Jsoup设置了Accept-Language的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有可能为Jsoup连接设置Accept-Language参数。
我试过:
Is there any possibility to set for the Jsoup connection the Accept-Language parameter.I've tried with:
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();
但不起作用...
推荐答案
您必须将标题
添加到连接
,如下所述
You have to add the Header
to the Connection
like mentioned below
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();
这篇关于Jsoup设置了Accept-Language的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!