• set http proxy on httpclient4


    //proxy
            InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("conf/system.properties");
           Properties properties = new Properties(); 
            try {
                properties.load(inputStream);
            } catch (IOException e) {
                // TODO Auto-generated catch block
                logger.debug("load system.properties failure...");
            } 
            String r=properties.getProperty("crawlNode.httpProxy", "none").toLowerCase().trim();
            if (!r.equals("none")){
                String[] arr=StringUtils.split(r, ":");
                int port=80;
                String url=r;
                if (arr.length==2)
                {
                    port=Integer.parseInt(arr[1]);
                    url=arr[0].trim();
                }
                HttpHost proxy = new HttpHost(url, port);
                params.setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
                logger.debug("start using http proxy {}:{}",url,port);
               
            }

  • 相关阅读:
    ye间模式
    Xutilt网络获取数据
    JUnit
    IntelliJ IDEA快捷键
    Map存放不同数据或对象
    SQL改
    外键约束
    Hibernate之SQL语言查询
    Hibernate之Criteria语言查询
    Hibernate之HQL语言查询
  • 原文地址:https://www.cnblogs.com/lexus/p/2480373.html
Copyright © 2020-2023  润新知