峰子_ 2019-03-09 17:26 采纳率: 100%
浏览 1381
已采纳

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

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

麻烦大佬解答一下 多谢

  • 写回答

4条回答

  • threenewbee 2019-03-09 23:47
    关注

    这种公开的代理服务器,肯定是很多黑产都在用,服务器肯定都封了。还能让你来用。
    另外就是代理服务器未必是匿名代理,如果是透明代理,还可以通过x-forward-for得到你原始的ip。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
  • ¥88 实在没有想法,需要个思路
  • ¥15 MATLAB报错输入参数太多
  • ¥15 python中合并修改日期相同的CSV文件并按照修改日期的名字命名文件
  • ¥15 有赏,i卡绘世画不出
  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败