雙色球2013年統計,從網上爬蟲出來的

來源:互聯網
上載者:User

標籤:des   blog   http   io   os   ar   java   for   sp   

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();}}

其中用到了jsoup的東西,具體的還不太會用。QQ:623687677.Java初學者

雙色球2013年統計,從網上爬蟲出來的

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.