我已经获取这个HTML的字符串```
现在就是要用正则获取我想要的天气的数据```
城市:深圳
日期:08年09月10日-11日 星期三
天气:晴
温度1:34
温度2:26
风力:≤3级
要获取3天天气信息已知字符穿里包含这样的信息:
<div class="City_Data">
<h3>今日 深圳</h3>
<p>08年09月10日-11日&nbsp;星期三</p>
</div>
<div class="Weather_Icon_B"><img src="http://image2.sina.com.cn/dy/weather/images/figure/qing_big.gif" ></div>
<div class="Weather_TP">晴 34℃~26℃</div>
<div class="Weather_W">&nbsp;风力:≤3级</div><div class="City_Data">
<h3>明日 深圳</h3>
<p>08年09月11日-12日&nbsp;星期四</p>
</div>
<div class="Weather_Icon_B"><img src="http://image2.sina.com.cn/dy/weather/images/figure/qing_big.gif" ><img src="http://image2.sina.com.cn/dy/weather/images/figure/duoyun_big.gif" ></div>
<div class="Weather_TP">晴转多云 35℃~27℃</div>
<div class="Weather_W">&nbsp;风力:≤3级</div>
<div class="City_Data">
<h3>后天 深圳</h3>
<p>08年09月12日-13日&nbsp;星期五</p>
</div>
<div class="Weather_Icon_B"><img src="http://image2.sina.com.cn/dy/weather/images/figure/duoyun_big.gif" ></div>
<div class="Weather_TP">多云 35℃~27℃</div>
<div class="Weather_W">&nbsp;风力:≤3级</div>
请问如何写正则抓取数据```
谢谢了``

解决方案 »

  1.   

    谁给我个WebServices地址也行`````
      

  2.   

    <h3>(?<text01>[^<]*)[\s\S]*?<p>(?<DateTime>[^\&]*)&nbsp;(?<Day>[^\<]*)</p>[\S\s]*?<div class="Weather_TP">(?<weather>[^<]*)</div>[\s\S]*?&nbsp;(?<wind>[^<]*)</div>
      

  3.   

    彻底点
                string strText = @"<div class=""City_Data""><h3>今日 深圳 </h3><p>08年09月10日-11日&nbsp;星期三 </p></div><div class=""Weather_Icon_B""> <img src=""http://image2.sina.com.cn/dy/weather/images/figure/qing_big.gif"" > </div><div class=""Weather_TP"">晴 34℃~26℃ </div><div class=""Weather_W"">&nbsp;风力:≤3级 </div><div class=""City_Data""><h3>明日 深圳 </h3><p>08年09月11日-12日&nbsp;星期四 </p></div><div class=""Weather_Icon_B""> <img src=""http://image2.sina.com.cn/dy/weather/images/figure/qing_big.gif"" > <img src=""http://image2.sina.com.cn/dy/weather/images/figure/duoyun_big.gif"" > </div><div class=""Weather_TP"">晴转多云 35℃~27℃ </div><div class=""Weather_W"">&nbsp;风力:≤3级 </div><div class=""City_Data""><h3>后天 深圳 </h3><p>08年09月12日-13日&nbsp;星期五 </p></div><div class=""Weather_Icon_B""> <img src=""http://image2.sina.com.cn/dy/weather/images/figure/duoyun_big.gif"" > </div><div class=""Weather_TP"">多云 35℃~27℃ </div><div class=""Weather_W"">&nbsp;风力:≤3级 </div>";
                Regex _regex = new Regex(@"<h3>(?<text01>[^<]*)[\s\S]*?<p>(?<DateTime>[^\&]*)&nbsp;(?<Day>[^\<]*)</p>[\S\s]*?<div class=.Weather_TP.>(?<weather>[^<]*)</div>[\s\S]*?&nbsp;(?<wind>[^<]*)</div>");
                MatchCollection _matchCollection = _regex.Matches(strText);            foreach (Match objMatch in _matchCollection)
                {
                    Console.WriteLine(objMatch.Groups["text01"].Value + "—" + objMatch.Groups["DateTime"].Value + "—" + objMatch.Groups["Day"].Value + "—" + objMatch.Groups["weather"].Value + "—" + objMatch.Groups["wind"].Value);
                }