双色球2013年统计,从网上爬虫出来的

package   com.hpu.bai;
 
import   java.io.BufferedReader;
import   java.io.BufferedWriter;
import   java.io.File;
import   java.io.FileOutputStream;
import   java.io.FileWriter;
import   java.io.IOException;
import   java.io.Writer;
import   java.net.URL;
 
import   org.jsoup.Jsoup;
import   org.jsoup.nodes.Document;
import   org.jsoup.nodes.Element;
import   org.jsoup.select.Elements;
 
public   class   Double2013 {
     public   static   void   main(String[] args) throws   Exception {
         Document doc;
         File file = new   File( "d:\\双色球第2013015期到2013154期开奖结果.txt" );
         FileOutputStream fos = new   FileOutputStream(file);
         //while(true){
             for ( int   i = 2013015 ;i<= 2013154 ;i++){
             String url = "http://caipiao.163.com/award/ssq/" +i+ ".html" ;
             doc  = (Document) Jsoup.connect(url).get();
             //String title = doc.title();
             //Elements ele = doc.select("div.search_zj_left p.red_ball span");
             Element content = doc.getElementById( "zj_area" );
             Elements links = content.getElementsByTag( "span" );
             //System.out.println(links.size());
             int   count = 0 ; byte [] b = new   byte [ 1024 ];
             for   (Element link : links) { 
                 count++;
                 //String linkHref = link.attr("href"); 
                 String linkText = link.text();
                 //System.out.print(linkHref);
                 System.out.print( " " +linkText);
                 //linkText.toCharArray();
                 linkText = " " +linkText;
                  b = linkText.getBytes();
                 fos.write(b);
                 if (count% 7   == 0 ){
                     fos.write( "\r\n" .getBytes());
                 }
                 }
                 System.out.println();
             //String ball = ele.text();
             /*Element dayFav = doc.getElementsByAttributeValue("class", "linkRight").first();
             Elements dayFavItems = dayFav.getElementsByTag("a");
             for (Element dayFavItem:dayFavItems) {
                 System.out.println(dayFavItem.text());
             } */
             //System.out.println(title);
             //System.out.println(ball);
             Thread.sleep( 1500 );
             }
         //}
     fos.flush();fos.close();
     }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值