Exemplo n.º 1
0
  public ArrayList<Yqjkxx> getNewsResources() {
    DBConn db = new DBConn();
    Statement st = null;
    ResultSet rs = null;
    Connection con = null;
    ArrayList<Yqjkxx> al = new ArrayList<Yqjkxx>();

    con = db.getConn();
    String sql = "select * from yqjk_task";
    try {
      st = con.createStatement();
      rs = (ResultSet) st.executeQuery(sql);
      while (rs.next()) {
        Yqjkxx yqjkxx = new Yqjkxx();
        yqjkxx.setRoleId(rs.getInt(1));
        yqjkxx.setRoleName(rs.getString(2));
        yqjkxx.setNewsResource(rs.getString(3));
        yqjkxx.setFindStyle(rs.getString(4));
        yqjkxx.setCollectDate(rs.getString(5));
        yqjkxx.setCollectCondition(rs.getString(6));
        yqjkxx.setContentMate(rs.getString(7));
        yqjkxx.setSite_collection(rs.getString(8));
        yqjkxx.setRoleState(rs.getString(9));
        al.add(yqjkxx);
      }
    } catch (SQLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } finally {
      db.close();
    }
    return al;
  }
Exemplo n.º 2
0
  public void insertReport(Report report) {

    ArrayList<Yqjkxx> resource = getNewsResources();

    for (Yqjkxx yqjkxx : resource) {
      String newsResource = yqjkxx.getNewsResource();
      String newsState = yqjkxx.getRoleState();

      if (newsResource.contains("新闻") && newsState.equals("启用")) {
        gnbk = new GetNewsByBaidu();
        gnbs = new GetNewsBySoso();
        wangyi = new GetNewsBy163();
        sina = new GetNewsBySina();
        sohu = new GetNewsBySohu();
        new3 = new GetNewsBy360();
        try {
          gnbk.getNews();
          loadBaiduData("D:" + File.separator + "newsbaidu.txt");
          gnbs.getSosoNews();
          wangyi.get163News();
          sina.getnewsBySina();
          sohu.getSohuNews();
          new3.get360News();
          loadNewsData("D:" + File.separator + "news.txt");
          TestTimer tt = new TestTimer();
          tt.useTimer();
        } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }
      if (newsResource.contains("贴吧") && newsState.equals("启用")) {
        GetNewsByTieba tieba = new GetNewsByTieba();
        try {
          tieba.getTiebaNews();
          loadTiebaData("D:" + File.separator + "tieba.txt");
        } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      } else if (newsState.equals("停用")) {
        System.out.println("此项已停用");
      }
    }
  }