---
title: "抓取新浪彩票数据"
author: "philip01"
date: "2009-08-06T15:44:15Z"
tags: []
slug: "untitled"
draft: false
lastmod: "2009-08-06T15:44:15Z"
id: 441682
url: "https://philip01.iteye.com/blog/441682"
---

package com.overseas;

import java.util.regex.Matcher;  
import java.util.regex.Pattern;

public class DownLoadDB {  
   
 public static void main(String\[] args) throws Exception{  
  String sCurrentLine;  
  String sTotalString;  
  sCurrentLine="";  
  sTotalString="";  
  java.io.InputStream l\_urlStream;  
  java.net.URL l\_url = new java.net.URL("[http://www.500wan.com/pages/info/datachart/ssq/history/inc/history.php?limit=0&start=09080&end=00000](http://www.500wan.com/pages/info/datachart/ssq/history/inc/history.php?limit=0&start=09080&end=00000)");  
  java.net.HttpURLConnection l\_connection = (java.net.HttpURLConnection) l\_url.openConnection();  
  l\_connection.connect();  
  l\_urlStream = l\_connection.getInputStream() ;  
  java.io.BufferedReader erl\_reader = new java.io.BufferedReader(new java.io.InputStreamReader(l\_urlStream));  
  while ((sCurrentLine = erl\_reader.readLine()) != null){  
   sTotalString+=sCurrentLine;  
  }  
  test(sTotalString);  
 }  
   
 public static void test(String txt){  
  String input = txt;  
    String exp1 = "\[\\\\s]\*\[&nbsp;]\*\[\\\\s]\*\[&nbsp;]\*(\[\\\\d, -]\*)\[\\\\s]\*\[&nbsp;]\*\[\\\\s]\*\[&nbsp;]\*";  
    String  regex = "&lt;tr class=\\"t\_tr1\\"&gt;&lt;!--&lt;td&gt;"+exp1+"&lt;/td&gt;--&gt;&lt;td&gt;"+exp1+"&lt;/td&gt;&lt;td class=\\"t\_cfont2\\"&gt;"+exp1+"&lt;/td&gt;&lt;td class=\\"t\_cfont2\\"&gt;"+exp1+"&lt;/td&gt;&lt;td class=\\"t\_cfont2\\"&gt;"+exp1+"&lt;/td&gt;&lt;td class=\\"t\_cfont2\\"&gt;"+exp1+"&lt;/td&gt;&lt;td class=\\"t\_cfont2\\"&gt;"+exp1+"&lt;/td&gt;&lt;td class=\\"t\_cfont2\\"&gt;"+exp1+"&lt;/td&gt;&lt;td class=\\"t\_cfont4\\"&gt;"+exp1+"&lt;/td&gt;&lt;td class=\\"t\_cfont4\\"&gt;"+exp1+"&lt;/td&gt;&lt;td&gt;"+exp1+"&lt;/td&gt;&lt;td&gt;"+exp1+"&lt;/td&gt;&lt;td&gt;"+exp1+"&lt;/td&gt;&lt;td&gt;"+exp1+"&lt;/td&gt;&lt;td&gt;"+exp1+"&lt;/td&gt;&lt;td&gt;"+exp1+"&lt;/td&gt;&lt;td&gt;"+exp1+"&lt;/td&gt;&lt;/tr&gt;";

 

   Pattern pattern = Pattern.compile(regex);  
   Matcher matcher = pattern.matcher(input);  
   while(matcher.find()){  
    for(int i=1; i&lt;=matcher.groupCount(); i++){  
       System.out.print(matcher.group(i) +"      ");  
   }  
    System.out.println("");  
    }  
    
 }  
 

}