62,268
社区成员
发帖
与我相关
我的任务
分享
WebClient wc = new WebClient();
string html = wc.DownloadString("http://youa.baidu.com/item/a808f4ea944a343ffc29cc4b");
Console.WriteLine(Regex.Match(html, @"((?<=<a\s+href=""http://youa.baidu.com/\S+&category=\S+"">).*?(?=</a>))").Value);
private void button1_Click(object sender, EventArgs e)
{
string html = @"<a href=""http://youa.baidu.com/search/s?search_domain=1"">所有分类</a> >
<a href=""http://youa.baidu.com/search/s?search_domain=1&category=50a4120bb2755c26f19e73fa"">手机</a>";
Match match = Regex.Match(html, @"<a\s+href="".*?"">所有分类</a>.*?<a\s+href="".*?"">(?<text>.*?)</a>",
RegexOptions.Singleline);
if (match.Success) Console.WriteLine(match.Result("${text}"));
}

WebClient wc = new WebClient();
string html = wc.DownloadString("http://youa.baidu.com/item/a003a463baa18aa5d2c2a69e");
Console.WriteLine(Regex.Match(html, @"<a href=""http://youa.baidu.com/\S+&category=\S+"">([^\<]+)</a>").Groups[1].Value);
/*
输出:
手机
*/
WebClient wc = new WebClient();
string html = wc.DownloadString("http://youa.baidu.com/item/a808f4ea944a343ffc29cc4b");
Console.WriteLine(Regex.Match(html, @"<a href=""http://youa.baidu.com/\S+&category=\S+"">([^\<]+)</a>").Groups[1].Value);
/*
输出:
女士箱包
*/