为什么Jsoup.connect("https://www.baidu.com").get() 可以访问,并成功返回200
public static void main(String[] args) throws Exception {
//Proxy proxy = new Proxy(Proxy.Type.HTTP,InetSocketAddress.createUnresolved("111.225.153.177", 8089));
Connection.Response response = Jsoup.connect("https://www.baidu.com").execute();
int code = response.statusCode();
System.out.println(code);
}
加了.proxy() 动态ip就不行了?
Jsoup.connect("https://www.baidu.com").proxy(proxy).get()
public static void main(String[] args) throws Exception {
Proxy proxy = new Proxy(Proxy.Type.HTTP,InetSocketAddress.createUnresolved("111.225.153.177", 8089));
Connection.Response response = Jsoup.connect("https://www.baidu.com").proxy(proxy).execute();
int code = response.statusCode();
System.out.println(code);
}
Exception in thread "main" java.net.ConnectException: Connection refused: connect
返回400或无法连接,这些动态ip我用Selenium测试都是可以的。