我将尝试爬取网页上的文章链接。
这是我的代码:
static void Main(string[] args)
{
WebClient web = new WebClient();
string html = web.DownloadString("http://www.dailymirror.lk");
MatchCollection m1 = Regex.Matches(html, @"<a href=""(.+?)""/s*class=""panel-heading"">",RegexOptions.Singleline);
foreach(Match m in m1)
{
Console.WriteLine(m.Groups[1].Value);
}
}
我所关注的页面HTML标记如下:
我正在专注于页面中的这个HTML标记:
<a href="http://www.dailymirror.lk/99833/ravi-s-budget-blues" class="panel-heading">
然而,我的代码无法检索链接,有什么办法可以改进我的代码吗?