c 使用正则获取html标签,C#使用正则表达式获取内容和下一个元素内的html标签

这是我的html:

Followed by

7,583 people

Friends

200 people

如您所见,有两个具有相同类名的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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值