zoukankan      html  css  js  c++  java
  • 废弃的java 爬虫代码

        protected static String getVersion(String filepath)
        {
            Properties system;
            String version="";
            try {
                system = PropertiesLoaderUtils.loadProperties(new ClassPathResource(filepath));
                version=StringUtils.toString(system.getProperty("crawlNode.version"));
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                logger.debug(e.toString());
            }
            return version;
        }
        protected static String buildCrawlParams() {
            // TODO Auto-generated method stub
            String result="";
            LinkedHashMap<String, String> params=new LinkedHashMap<String, String>();
            InetAddress inet;
            try {
                inet = InetAddress.getLocalHost();
                String ip=StringUtils.toString(inet.getHostAddress());
                params.put("ip", ip);
               
                String hostname=inet.getHostName();
                params.put("hostname", hostname);
               
                logger.debug("ip:{}",ip);
                logger.debug("hostname:{}",hostname);
                logger.debug("version:{}",getVersion("conf/system.properties"));
                ObjectMapper mapper=new ObjectMapper();
                result=mapper.writeValueAsString(params);
            } catch (Exception e) {
                // TODO Auto-generated catch block
                logger.warn("获取抓取机环境参数出现错误");
            }
            logger.info("final crawlParams:{}",result);
            return result;

        }

  • 相关阅读:
    python 求取代码运行时间
    Python中的继承、抽象基类和接口
    Python安装和环境配置,让你轻松入门学习Python!
    python入门python的基本语法
    没有对象?程序员的浪漫,对象攻略(1)
    python实现邮件循环自动发件
    docker查看全部容器命令
    python speech模块的使用方法
    开宗立派宣言
    多个 (li) 标签如何获取获取选中的里面的某个特定值
  • 原文地址:https://www.cnblogs.com/lexus/p/2407323.html
Copyright © 2011-2022 走看看