Get Text from a Web Page C#

How can I get the text "GYMMW-2P7QD-WK43P-H6XK4-QT9YZ" from http://mailinator.com/displayemail.jsp?email=hi911&msgid=3356249 ?
Se7enFreakAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

käµfm³d 👽Commented:
Try this:
using (System.Net.WebClient client = new System.Net.WebClient())
{
    string pageData = client.DownloadString("http://mailinator.com/displayemail.jsp?email=hi911&msgid=3356249");

    string value = System.Text.RegularExpressions.Regex.Match(pageData, "[A-Z0-9-]{29}").Value;

    return value;
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MajorBigDealCommented:
Since I don't have credentials to see that email,  the page that is served to me does not contain the string that you are looking for.   Tthe previous suggestion is good,  giving any 29 character strings made from capitals, digits, and dashes.  You might get more matches than you are looking for though.  

If you want something  more specific, you could post the portion of the page source code that contains the string in question so it could be narrowed down.
0
käµfm³d 👽Commented:
You might get more matches than you are looking for though.
I agree. I was being lazy. If you wanted a more defined pattern, you could change it to:
(?:[A-Z0-9]{5}-){4}[A-Z0-9]{5}

Open in new window

0
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

Se7enFreakAuthor Commented:
How bout from this HTML?

<span id="ctl00_ContentPlaceHolder2_lblMessage" style="display:inline-block;width:606px;">

<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>COMPUTER BILD SPIELE-Aktion</title>



<a href="http://www.computerbild.de/cbs/index.html"><img src="http://img.computerbild.de/img/logo_cbs.gif" style="border-width: 0px;"></a>
<table border="0" cellpadding="5" cellspacing="0" width="500" style="border-width: 1px; border-color: rgb(178,178,178); border-style: solid;">
  
    <tbody><tr>
        <td width="1101">
            <p><font face="Tahoma" size="3">
</font></p><p><font face="Tahoma" size="3"><font face="Tahoma">Ihre Seriennummer lautet:</font></font></p><font face="Tahoma" size="3"><font face="Tahoma" size="4"><b>HQ6CV-KFDYG-XGCY6-R26DV-DV36Z</b></font>
        </font></td>
    </tr>
</tbody></table>
<p>&nbsp;</p>
<p><a href="http://www.computerbild.de/newsletter.html">Jetzt anmelden: Mit den Newslettern von COMPUTER BILD, COMPUTER BILD SPIELE und AUDIO VIDEO FOTO BILD bleiben Sie stets auf dem Laufenden.</a></p>



</span>

Open in new window

0
käµfm³d 👽Commented:
How bout from this HTML?
Did you try the code? It should work for either.
0
MajorBigDealCommented:
Thanks for posting the HTML. I reviewed it and unfortunately don't see anything stable to leverage from. It can be done but it would be fragile so I would not recommend doing it that way. I tried kaufmed's code and it does work, assuming that you are always dealing with 5 groups of 5 and that there is only one such group in the the page. If you still want to see an html parse example just let me know.  
0
Se7enFreakAuthor Commented:
Perfect
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.