简体   繁体   English

Jsoup html解析区域语言设置java

[英]Jsoup html parse region language settings java

How can I parse HTML data like I were in other country? 我如何像在其他国家/地区一样解析HTML数据?

I've tried to use proxy (code): 我试过使用代理(代码):

System.setProperty("http.proxyHost", "some proxy");
System.setProperty("http.proxyPort", "some port");

but it doesn't work properly. 但它不能正常工作。 I still get data in my country language. 我仍然使用我的国家语言获取数据。

I've also tried using VPN, but when I do my program (Jsoup parser) doesn't download anything. 我也尝试过使用VPN,但是当我执行我的程序(Jsoup解析器)时不会下载任何东西。

EDIT: 编辑:

Thanks for your time, the marked answer helped me to solve the problem. 感谢您的时间,明确的答案帮助我解决了问题。 The complete solution I found there . 完整的解决方案,我发现那里

That depends on the site you're trying to download. 这取决于您尝试下载的网站。 If the site is using IP geolocation, the only solution is to use appropiate proxy: https://stackoverflow.com/a/1433296/1608594 如果该站点使用IP地理定位,唯一的解决方案是使用适当的代理: https//stackoverflow.com/a/1433296/1608594

If the site is only using HTTP headers to determine language, you can send Accept-Language , Accept-Charset and Accept-Encoding headers with the proper values. 如果站点仅使用HTTP标头来确定语言,则可以使用正确的值发送Accept-LanguageAccept-CharsetAccept-Encoding标头。 https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Request_fields https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Request_fields

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM