如何使用jsoup将正确的字符集设置为代理服务器?

l7wslrjt  于 2021-07-09  发布在  Java
关注(0)|答案(1)|浏览(293)

这个代码给我的内容,但一些俄罗斯字符为我隐藏的广场。。。谁知道如何设置utf-8或cp1251字符集代理获得内容。与代码共舞不要为我接受任何结果。getbytes和其他方法不能给我正常的结果。

URL url = new URL(linkCar);
String your_proxy_host = new String(proxys.getValueAt(xProxy, 1).toString());
int your_proxy_port = Integer.parseInt(proxys.getValueAt(xProxy, 2).toString());
Proxy proxy = null;
System.out.println(proxys.getValueAt(xProxy, 3).toString());
proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(your_proxy_host, your_proxy_port));
HttpURLConnection connection = (HttpURLConnection)url.openConnection(proxy);
connection.setConnectTimeout(16000);
connection.connect();

proxys—代理列表所在的表模型;可能是知道如何设置代理的人

7tofc5zh

7tofc5zh1#

对于utf-8,尝试更改线路

BufferedReader buffer_input = new BufferedReader(new InputStreamReader(connection.getInputStream()));

BufferedReader buffer_input = new BufferedReader(new InputStreamReader(connection.getInputStream(),"UTF-8"));

如果要更改字符集,可以将字符集名称更改为其他名称。

相关问题