Reputation: 462
This is my html:
<div class="_50f3">
Followed by
<a href="https://www.facebook.com/zurabj/followers">
7,583 people
</a>
</div>
<div class="_50f3">
Friends
<a href="https://www.facebook.com/zurabj/followers">
200 people
</a>
</div>
As you can see there are two divs with the same classname. What i want to achive is to get followers count(7583 people). I know this would be easy with htmlagilitypack, but in this case i can't use it and need to solve the problem with regex, but can't figure out how.
And problem also is that, i don't know ordering, sometimes friends count is inside the first and sometimes in the second div.
Upvotes: 3
Views: 873
Reputation: 462
Okey i solve the problem
string html = fb.GetHtml("https://www.facebook.com/zurabj?fref=ts");
string pattern = "<div class=\"_50f3\".*?>(.*?)<\\/div>";
MatchCollection matches = Regex.Matches(html, pattern);
foreach (Match m in matches)
{
if (m.ToString().Contains("Followed by"))
{
Match count = Regex.Match(m.ToString(), "<a .*?>(.*?)<\\/a>");
string counterString = count.Groups[1].ToString();
}
Upvotes: 3