weixin_37744601
峰子_
2019-03-09 17:26

爬虫代理ip无法使用,换了好几个了都一样

  • java
public static void main(String[] args) throws IOException {

        Map<String,String> header=new HashMap<>();

        header.put("Accept","text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
        header.put("Accept-Language","zh-CN,zh;q=0.8");
        header.put("Cache-Control","max-age=0");
        header.put("Connection","keep-alive");
        header.put("Host","www.xicidaili.com ");
        header.put("If-None-Match","W/\"f9ed210d1bd9f787ddddffceef37c9bc\"");
        header.put("User-Agent","Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 SE 2.X MetaSr 1.0");
        header.put("Upgrade-Insecure-Requests","1");

        String content=Jsoup.connect("https://www.xicidaili.com/wt/").referrer("https://www.xicidaili.com/wn")
                .proxy("59.62.164.68", 9999)
                .ignoreContentType(true)
                .ignoreHttpErrors(true)
                .headers(header)
                .execute().parse()
                .toString();
        System.out.println(content);
    }

请问我这个为啥一直报这个错误
Exception in thread "main" java.net.ConnectException: Connection refused: connect

代理ip我已经换了好几个 都是这样
代理ip来源:https://www.xicidaili.com

麻烦大佬解答一下 多谢

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答