这是我的html:
如您所见,有两个具有相同类名的div.我要达到的目标是吸引追随者人数(7583人).我知道使用htmlagilitypack会很容易,但是在这种情况下,我将无法使用它,并且需要使用正则表达式解决问题,但无法弄清楚该怎么做.
问题还在于,我不知道订购,有时朋友数在第一区域内,有时在第二区域内.
解决方法:
好吧,我解决了这个问题
string html = fb.GetHtml("https://www.facebook.com/zurabj?fref=ts");
string pattern = "
(.*?)";
MatchCollection matches = Regex.Matches(html, pattern);
foreach (Match m in matches)
{
if (m.ToString().Contains("Followed by"))
{
Match count = Regex.Match(m.ToString(), "(.*?)");
string counterString = count.Groups[1].ToString();
}
标签:c,regex
来源: https://codeday.me/bug/20191119/2034833.html