62,047
社区成员
发帖
与我相关
我的任务
分享
<!--day 1-->
<table class="yuBaoTable" width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="15%" rowspan="2" class="t0" style="background:#f4f7fc;"><a title="农历六月初一">1日星期五</a></td>
<td width="12%" style="background:#f4f7fc;">白天</td>
<td width="10%">
<a href="http://www.weather.com.cn/static/html/legend.shtml" target="_blank">
<img src="/m2/i/icon_weather/29x20/d00.gif" />
</a>
</td>
<td width="18%"><a href ="http://baike.weather.com.cn/index.php?doc-view-767.php" target="_blank">晴</a></td>
<td width="15%">
<a href="http://baike.weather.com.cn/index.php?doc-view-1148.php" target="_blank">
<b>高温 <strong>34<strong>℃</b>
</a>
</td>
<td width="15%">
<a href="http://baike.weather.com.cn/index.php?doc-view-778.php" target="_blank">
无持续风向
</a>
</td>
<td width="15%">
<a href="http://baike.weather.com.cn/index.php?doc-view-778.php" target="_blank">
微风
</a>
</td>
</tr>
<tr>
<td style="background:#f4f7fc;">夜间</td>
<td>
<a href="http://www.weather.com.cn/static/html/legend.shtml" target="_blank">
<img src="/m2/i/icon_weather/29x20/n01.gif" />
</a>
</td>
<td><a href ="http://baike.weather.com.cn/index.php?doc-view-769.php" target="_blank">多云</a></td>
<td>
<a href="http://baike.weather.com.cn/index.php?doc-view-1386.php" target="_blank">
<span>低温 <strong>26<strong>℃</span>
</a>
</td>
<td>
<a href="http://baike.weather.com.cn/index.php?doc-view-778.php" target="_blank">
无持续风向
</a>
</td>
<td>
<a href="http://baike.weather.com.cn/index.php?doc-view-778.php" target="_blank">
微风
</a>
</td>
</tr>
</table>
<!--day 2-->
public string[] htmlCrwal4(string htmlstr, string begstr, string endstr)
{
string temp = "";
int start, stop;
// start = HTML.IndexOf("</style>", 0, HTML.Length);``
start = htmlstr.IndexOf(begstr, 0, htmlstr.Length);
stop = htmlstr.IndexOf(endstr, 0, htmlstr.Length);
temp = htmlstr.Substring(start, stop - start);
Regex regex = new Regex("<[^>]*>");
string[] ss = regex.Split(temp);
string t = "";
foreach (string p in ss)
if (p.Trim().Length > 0)
t += p + "/";
string[] sss = t.Split('/');
return sss;
}
htmlCrwal4(htmlstring,"<!--day 1-->","<!--day 2-->"),
void Main()
{
string html = @"<!--day 1-->
<table class=""yuBaoTable"" width=""100%"" border=""0"" cellspacing=""0"" cellpadding=""0"">
<tr>
<td width=""15%"" rowspan=""2"" class=""t0"" style=""background:#f4f7fc;""><a title=""农历六月初一"">1日星期五</a></td>
<td width=""12%"" style=""background:#f4f7fc;"">白天</td>
<td width=""10%"">
<a href=""http://www.weather.com.cn/static/html/legend.shtml"" target=""_blank"">
<img src=""/m2/i/icon_weather/29x20/d00.gif"" />
</a>
</td>
<td width=""18%""><a href =""http://baike.weather.com.cn/index.php?doc-view-767.php"" target=""_blank"">晴</a></td>
<td width=""15%"">
<a href=""http://baike.weather.com.cn/index.php?doc-view-1148.php"" target=""_blank"">
<b>高温 <strong>34<strong>℃</b>
</a>
</td>
<td width=""15%"">
<a href=""http://baike.weather.com.cn/index.php?doc-view-778.php"" target=""_blank"">
无持续风向
</a>
</td>
<td width=""15%"">
<a href=""http://baike.weather.com.cn/index.php?doc-view-778.php"" target=""_blank"">
微风
</a>
</td>
</tr>
<tr>
<td style=""background:#f4f7fc;"">夜间</td>
<td>
<a href=""http://www.weather.com.cn/static/html/legend.shtml"" target=""_blank"">
<img src=""/m2/i/icon_weather/29x20/n01.gif"" />
</a>
</td>
<td><a href =""http://baike.weather.com.cn/index.php?doc-view-769.php"" target=""_blank"">多云</a></td>
<td>
<a href=""http://baike.weather.com.cn/index.php?doc-view-1386.php"" target=""_blank"">
<span>低温 <strong>26<strong>℃</span>
</a>
</td>
<td>
<a href=""http://baike.weather.com.cn/index.php?doc-view-778.php"" target=""_blank"">
无持续风向
</a>
</td>
<td>
<a href=""http://baike.weather.com.cn/index.php?doc-view-778.php"" target=""_blank"">
微风
</a>
</td>
</tr>
</table>
<!--day 2-->";
string[] result= Regex.Replace(html,"<[^>]*>","/").Split(new char[]{'/'},StringSplitOptions.RemoveEmptyEntries).Where(s=>!string.IsNullOrEmpty(s.Trim())).ToArray();
result.ToList().ForEach(s=>Console.WriteLine(s.Trim()));
/*
1日星期五
白天
晴
高温
34
℃
无持续风向
微风
夜间
多云
低温
26
℃
无持续风向
微风
*/
}