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?
 
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
 
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
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.