jsoup 는 표 의 내용 을 기어 올 랐 다.

9972 단어 자바
import java.io.IOException;
import java.util.Date;
import java.util.List;
import java.lang.*;
import java.text.SimpleDateFormat;

import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import com.ecai.entity.ecaibm.FtbInfo;

public class JsoupUtil {
    //         
    public static PageData sfcSs(){
         Document doc = null;
         PageData pd = new PageData();
         SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");//      
            String  datestr = df.format(new Date());
            pd.put("INSERT_TIME", datestr);
            try {
                doc = Jsoup.connect("http://caipiao.163.com/order/sfc/").get();             
                pd.put("COMPETE_14_ID", UuidUtil.get32UUID());
                 Element singerListDiv = doc.getElementsByAttributeValue("class", "sfc_table").first();
                Elements listDiv = doc.getElementsByAttributeValue("class", "c_fff");
                //       “c_fff”       ,       ss 
                String ss = doc.getElementsByAttributeValue("class", "c_fff").text();
                ss = ss.replace(" ", ",");
                String[] saishi = ss.split(",");    
              //      
                String line = doc.getElementsByAttributeValue("id", "bet_time").text();
                line = line.substring(6,22);
                pd.put("DEADLINE",line);
                //  
                String term = doc.getElementsByAttributeValue("id", "bet_period").text();
                pd.put("TERM",term);
                //  
                String ss = doc.getElementsByAttributeValue("class", "c_fff").text();
                ss = ss.replace(" ", ",");
                pd.put("SAISHI",ss);
                //    
                Elements trs = doc.select("table.sfc_table").select("tr");
                StringBuffer time = new StringBuffer();;
                for(int i = 0;i
                    Elements tds = trs.get(i).select("td");                 
                    if(tds.size()>3){
                        String text = tds.get(2).text();
                        time.append(text+",");
                    }
                }
                String tm = time.toString();
                pd.put("START_TIME",tm);
              //    
                String t = doc.getElementsByAttributeValue("class", "c_2b2b2b").text();
                t = t.replace(" ", ",");
                pd.put("TEAM",t);
            } catch (IOException e) {
                e.printStackTrace();
            }
            return pd;
    }
}

좋은 웹페이지 즐겨찾기