我想取得http://www.zjlottery.com/win/winL.asp?newsid=64291这个网页中的:超级大乐透35选5加12选2  第 10077 期   全国投注总额: 51385724元    06   07   09   17   24   02   12 
一等奖 0 0    二等奖 3 1018831                    这些信息    请大家帮忙一下。

解决方案 »

  1.   

    这个是可以的,下面是源文件:<html>
    <head>
    <meta NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <meta NAME="Description" CONTENT>
    <meta name="keywords" content>
    <meta HTTP-EQUIV="REFRESH" CONTENT="3600">
    <title>浙江体育彩票超级大乐透35选5加12选2开奖公告</title>
    </head>
    <style type="text/css">
    table{
    font-size:12px;
    }
    </style><body topmargin="0" leftmargin="0" rightmargin="0">
    <table border="0" cellpadding="0" cellspacing="0" width="100%" background="/v4.03/winimg/back_3.gif" align="center" height="100%">
    <tr>
    <td><div align="center"><img src="/v4.03/winimg/publac_1.gif" WIDTH="279" HEIGHT="107"></div></td>
    </tr>
    <tr height="90">
    <td valign="top">
    <br>
    <table border="0" align="center" cellpadding="0" cellspacing="0" width="80%" style="color:#875E5E">
    <tr>
    <td>“超级大乐透35选5加12选2”第&nbsp;10077&nbsp;期</td>
    <td align="right">
    全国投注总额:&nbsp;51385724元
    <!--全国追加投注总额:&nbsp;0元-->
    <!--<BR> 浙江投注总额:&nbsp;4480727元-->
    <!--浙江追加投注总额:&nbsp;0元-->
    </td>
    </tr>
    <tr>
    <td colspan="2" valign="top"><br>
    <table border="0" cellpadding="0" cellspacing="0" align="left">
    <tr>
    <td width="88"><img src="/v4.03/winimg/qianqu.gif" WIDTH="88" HEIGHT="19"></td>
    <td background="/v4.03/winimg/affiche_1.gif" height="31" width="31" align="absmiddle">&nbsp;&nbsp;06</td>
    <td background="/v4.03/winimg/affiche_1.gif" height="31" width="31" align="absmiddle">&nbsp;&nbsp;07</td>
    <td background="/v4.03/winimg/affiche_1.gif" height="31" width="31" align="absmiddle">&nbsp;&nbsp;09</td>
    <td background="/v4.03/winimg/affiche_1.gif" height="31" width="31" align="absmiddle">&nbsp;&nbsp;17</td>
    <td background="/v4.03/winimg/affiche_1.gif" height="31" width="31" align="absmiddle">&nbsp;&nbsp;24</td>

    <td width="82"><img src="/v4.03/winimg/houqu.gif" WIDTH="82" HEIGHT="19"></td>
    <td background="/v4.03/winimg/affiche_1.gif" height="31" width="31" align="absmiddle">&nbsp;&nbsp;02</td>
    <td background="/v4.03/winimg/affiche_1.gif" height="31" width="31" align="absmiddle">&nbsp;&nbsp;12</td>
    </tr>
    </table>
    </td>
    </tr>


    <tr>
    <td><br>超级大乐透&nbsp;&nbsp;超越500万</td>
    <td align="right" valign="bottom"><br>●代表前区号码&nbsp;&nbsp;&nbsp;○代表后区号码</td>
    </tr>
    </table>
    </td>
    </tr>
    <tr>
    <td valign="top">
    <table border="0" cellpadding="0" cellspacing="0" width="612" align="center">

    <tr>
    <td width="4" background="/v4.03/winimg/publac_4.gif"></td>
    <td width="606" valign="top" bgcolor="#1979D3">
    <table border="1" frame="void" cellpadding="0" cellspacing="0" width="606" bordercolorlight="#0962B6" bordercolordark="#ffffff" style="color:#FFFA3B;text-align:center">
    <tr height="20" background="/images/winimg/297top.gif">
    <td width="90" align="center" colspan="2">奖 级</td>
    <td width="87" align="center">全国中奖注数</td>
    <!--<td width="87" align="center">浙江中奖注数</td>-->
    <td width="204" align="center">每 注 奖 金</td>
    <td align="center">中 奖 条 件</td>
    </tr>
    <tr height="25">
    <td rowspan="2">一等奖</td>
    <td>基本投注</td>
    <td>0</td>
    <!--<td>0</td>-->
    <td width="204">0</td>
    <td align="left" rowspan="2">● ● ● ● ●+○○</td>
    </tr>
    <tr height="25">
    <td>追加投注</td>
    <td>0</td>
    <!--<td>0</td>-->
    <td width="204">0</td>
    </tr>
    <tr height="25">
    <td rowspan="2">二等奖</td>
    <td>基本投注</td>
    <td>3</td>
    <!--<td>1</td>-->
    <td width="204">1018831</td>
    <td align="left" rowspan="2">● ● ● ● ●+○</td>
    </tr>
    <tr height="25">
    <td>追加投注</td>
    <td>1</td>
    <!--<td>0</td>-->
    <td width="204">611298</td>
    </tr>
    <tr height="25">
    <td rowspan="2">三等奖</td>
    <td>基本投注</td>
    <td>38</td>
    <!--<td>3</td>-->
    <td width="204">22364</td>
    <td align="left" rowspan="2">● ● ● ● ●</td>
    </tr>
    <tr height="25">
    <td>追加投注</td>
    <td>5</td>
    <!--<td>0</td>-->
    <td width="204">13418</td>
    </tr>

    <tr height="25">
    <td rowspan="2">四等奖</td>
    <td>基本投注</td>
    <td>40</td>
    <!--<td>5</td>-->
    <td width="204">3000</td>
    <td align="left" rowspan="2">● ● ● ●+○ ○</td>
    </tr>
    <tr height="25">
    <td>追加投注</td>
    <td>9</td>
    <!--<td>0</td>-->
    <td width="204">1500</td>
    </tr>
    <tr height="25">
    <td rowspan="2">五等奖</td>
    <td>基本投注</td>
    <td>1473</td>
    <!--<td>107</td>-->
    <td width="204">600</td>
    <td align="left" rowspan="2">● ● ● ●+○</td>
    </tr>
    <tr height="25">
    <td>追加投注</td>
    <td>464</td>
    <!--<td>33</td>-->
    <td width="204">300</td>
    </tr>
    <tr height="25">
    <td rowspan="2">六等奖</td>
    <td>基本投注</td>
    <td>6540</td>
    <!--<td>509</td>-->
    <td width="204">100</td>
    <td align="left" rowspan="2">● ● ● ●或● ● ●+○ ○</td>
    </tr>
    <tr height="25">
    <td>追加投注</td>
    <td>1573</td>
    <!--<td>74</td>-->
    <td width="204">50</td>
    </tr>
    <tr height="25">
    <td rowspan="2">七等奖</td>
    <td>基本投注</td>
    <td>69490</td>
    <!--<td>5227</td>-->
    <td width="204">10</td>
    <td align="left" rowspan="2">● ● ●+○或● ●+○ ○</td>
    </tr>
    <tr height="25">
    <td>追加投注</td>
    <td>18273</td>
    <!--<td>1558</td>-->
    <td width="204">5</td>
    </tr>

    <tr height="25">
    <td colspan="2">八等奖</td>
    <td>832924</td>
    <!--<td>67088</td>-->
    <td width="204">5</td>
    <td align="left">● ● ●或● ●+○或●+○ ○或○ ○</td>
    </tr>
    </table>
    </td>
    <td width="2" background="/v4.03/winimg/publac_5.gif"></td>
    <tr>
    <tr>
    <td colspan="3" height="5" align="center" valign="top"><img src="/v4.03/winimg/affiche_7.gif" WIDTH="612" HEIGHT="5"></td>
    </tr>
    </table>
    </td>
    </tr>
    <tr>
    <td valign="top"><br>
    <table border="0" cellpadding="0" cellspacing="0" width="600" align="center">
    <tr>
    <td colspan="2" style="color:#CD0707">
     &nbsp;&nbsp;&nbsp;&nbsp;兑奖有效期:自7月5日起60个自然日。<br>
    <br> </td>
    </tr>

    <tr>
    <td colspan="2" style="color:#CD0707;line-height:50px;font-size:20px;font-weight:700" align="center">本期累积奖金总额6819.2388万元全额滚入下期</td>
    </tr>

    <tr>
    <td align="left"><img src="/v4.03/winimg/w3.gif" WIDTH="140" HEIGHT="38"></td>
                 
    <td align="right" style="color:#CD0707">2010年7月5日&nbsp;&nbsp;&nbsp;&nbsp;
    </td>
    </tr>
    </table>
    </td>
    </tr>
    </table></body>
    </html>
      

  2.   


    static void Main(string[] args)
    {
        string html = Encoding.GetEncoding("GB2312").GetString(new WebClient().DownloadData("http://www.zjlottery.com/win/winL.asp?newsid=64291"));
        Match m = Regex.Match(html, @"(?is)“(?<wf>超级大乐透35选5加12选2”第&nbsp;10077&nbsp;期).+?(?<qgtz>全国投注总额:[^元]+元).+?(.+?&nbsp;&nbsp;(?<ball>\d{2}).+?)+.+?</table>");
        if (!m.Success) return;
        Console.WriteLine(m.Groups["wf"].Value.Replace("&nbsp;", " "));
        Console.WriteLine(m.Groups["qgtz"].Value.Replace("&nbsp;", " "));
        foreach (Capture c in m.Groups["ball"].Captures)
        {
            Console.Write(c.Value + " ");
        }
        Console.ReadKey();
    }
    结果:超级大乐透35选5加12选2”第 10077 期
    全国投注总额: 51385724元
    6 07 09 17 24 02 12
      

  3.   


    private static void TestRegex03()
    {
        string html = Encoding.GetEncoding("GB2312").GetString(new WebClient().DownloadData("http://www.zjlottery.com/win/winL.asp?newsid=64291"));
        Match m = Regex.Match(html, @"(?is)“(?<wf>超级大乐透35选5加12选2”第&nbsp;\d+&nbsp;期).+?(?<qgtz>全国投注总额:[^元]+元).+?(.+?&nbsp;&nbsp;(?<ball>\d{2}).+?)+.+?</table>");
        if (!m.Success) return;
        Console.WriteLine(m.Groups["wf"].Value.Replace("&nbsp;", " "));
        Console.WriteLine(m.Groups["qgtz"].Value.Replace("&nbsp;", " "));
        foreach (Capture c in m.Groups["ball"].Captures)
        {
            Console.Write(c.Value + " ");
        }
    }
      

  4.   

     public string Getdata2(string str)
            {
                string data2 = "";
                Match m = Regex.Match(str, @"(?is)“(?<wf>超级大乐透35选5加12选2”第&nbsp;\d+&nbsp;期).+?(?<qgtz>全国投注总额:[^元]+元).+?(.+?&nbsp;&nbsp;(?<ball>\d{2}).+?)+.+?</table>");
                if (!m.Success)
                    return;
                data2+=m.Groups["wf"].Value.Replace("&nbsp;", " ");
                data2+=m.Groups["qgtz"].Value.Replace("&nbsp;", " ");
                foreach (Capture c in m.Groups["ball"].Captures)
                {
                    data2 += c.Value;
                }
                return data2;
            源代码下载好了,我想把这些信息保存为一个字符串,对逍遥兄的改了后出了点问题,请帮忙看下,
    错误 CS0126: 需要一个类型可转换为“string”的对象
      

  5.   

    return; 你函数要返回一个值
    改为
    return data2;
      

  6.   

    foreach (Capture c in m.Groups["ball"].Captures)
      {
      data2 += c.Value;
      }
    capture是啥类型?重写个ToString()吧,如果c.value是简单类型那就:
    data2 += c.Value.ToString();
      

  7.   

    逍遥兄给的能成功得到答案,还能不能帮忙解释一下:(?<ball>\d{2}).+?)+.+?</table>")这句怎么理解??
    十分感谢!
      

  8.   

    (?<ball>\d{2}).+?)+.+?</table>
    (?<ball>)  分组捕获,将\d{2}保存为ball分组在后续的Groups["ball"]能得到。
    其他的没啥特殊的,看看正则语法吧。正则表达式语法
    过客的博客
      

  9.   

    private static void TestRegex03()
    {
        string html = Encoding.GetEncoding("GB2312").GetString(new WebClient().DownloadData("http://www.zjlottery.com/win/winL.asp?newsid=64291"));
        Match m = Regex.Match(html, @"(?is)“(?<wf>超级大乐透35选5加12选2”第&nbsp;\d+&nbsp;期).+?(?<qgtz>全国投注总额:[^元]+元).+?(.+?&nbsp;&nbsp;(?<ball>\d{2}).+?)+.+?</table>.+?一等奖\D.+?<td>(?<jb>\d+)\D+(?<zj>\d+)");
        if (!m.Success) return;
        Console.WriteLine(m.Groups["wf"].Value.Replace("&nbsp;", " "));
        Console.WriteLine(m.Groups["qgtz"].Value.Replace("&nbsp;", " "));
        foreach (Capture c in m.Groups["ball"].Captures)
        {
            Console.Write(c.Value + " ");
        }
        Console.WriteLine("一等奖 基本投注:"+m.Groups["jb"].Value);
        Console.WriteLine("一等奖 追加投注:"+m.Groups["zj"].Value);
    }