public GuoJiPrice GetGuoJiPriceInfo(string url)
{
try
{
string now = DateTime.Now.ToString("yyyy-MM-dd");
url = string.Format("{0}_{1}_{1}_1.htm", url, now);//参数指定爬取页
string form = Http.GetHtml(url, ref cookie);
form = Other.GetRegValue("<tr><td((?!</tr>).)+", form);
MatchCollection matches = Other.GetRegValues("<td((?!</td>).)+", form);
string a = Other.GetRegValue(@".*", matches[1].Value);//匹配第一个单元格的内容
string b = Other.GetRegValue(@".*", matches[2].Value);
string c = Other.GetRegValue(@".*", matches[3].Value);
string d = Other.GetRegValue(@".*", matches[4].Value);
return new GuoJiPrice(a, b, c, d, now); }
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return null;
}
}
这样我能读取一张表格上的第一行中的4个单元格的内容,如果这张表格里有多行需要的数据,想遍历这张表格,然后获取所有想要的内容,循环遍历应该怎么写?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货