zeynab farzaneh
zeynab farzaneh

Reputation: 539

how extract email from fb html c#

Facebook emails in html page will show as below.

<ul class="uiList _4kg">

<li>

rezarezvan110&#064;hotmail.com

<span class="pls inlineLabel">(Windows Live Messenger)</span>

</li>

 <li>

<a href="ymsgr:sendim?yasin_zfarzaneh%40yahoo.com">

    <span>yasin_zfarzaneh&#064;yaho</span>

    <wbr />

    <span class="word_break">

    </span>o.com
</a>

<span class="pls inlineLabel">(Yahoo! Messenger)</span>

</li>

know i want extracted email of it , how can i do it ? i used this method but dont return anything

 public static List<string> Fetch_Emails1(string Sourcecode)
    {
        List<string> Emails = new List<string>();


      Regex exp = new Regex(@".*?(&#064;)", RegexOptions.IgnoreCase);
        MatchCollection matchCollection = exp.Matches(Sourcecode);

        foreach (Match m in matchCollection)
        {

            Emails.Add(m.Value);

        }



        return Emails;
    }

how change pattern for extract email ?

Upvotes: 0

Views: 365

Answers (1)

Pantelis Natsiavas
Pantelis Natsiavas

Reputation: 5369

Basing your code on another web application's page parsing is error prone and very difficult to maintain. Imagine that if facebook changes the rendered HTML, your application won't work.

I would strongly suggest to use some facebook API. Check facebook SDK for .NET or Facebook API for C#.NET developers on codeplex.

Regarding the emails, you have to check the permissions issue. This post gives details.

Hope I helped!

Upvotes: 1

Related Questions