Select specific text?

Hello Experts:

I'm using a webform to populate a textbox with text from a website.  I use this function:

Function GetHtmlPage(ByVal strURL As String) As String
        Dim strResult As String
        Dim objResponse As WebResponse
        Dim objRequest As WebRequest = HttpWebRequest.Create(strURL)
        objResponse = objRequest.GetResponse()
        Dim sr As New StreamReader(objResponse.GetResponseStream())
        strResult = sr.ReadToEnd()
        msgbox.Text = strResult
        sr.Close()
    End Function

This works for me just fine but I have no clue how to get the specific text I need from that webpage.  There is a table on this page:

<table cellspacing="0" class="srpFooterTable">
        <tr>
            <td colspan="2"><a href="/help/cms_article_page.jsp?contentid=22594#21940185" class="bold-link">Advertised Price Range</a> for this search</td>
        </tr>
<tr>
            <td class="srpFooterTD">$12,900</td>
            <td>Highest price</td>
        </tr>
        <tr>
            <td class="srpFooterTD">$7,499</td>
            <td>Lowest price</td>
        </tr>
        <tr>
            <td class="srpFooterTD">$9,449</td>
            <td>Average price</td>
        </tr>
</table>
I really want to grab those three dollar values and store them in three different textboxes.  How do I do this?
jay-areAsked:
Who is Participating?
 
Solar_FlareCommented:
regular expressions would be the easiest

dim r as new Regex(">$([0-9|,|.]+)<")
dim mc as MatchCollection = r.matches(htmlstring)
for each m as match in mc
   dim s as string = m.Groups(1).ToString()
   ''do something with s
next
0
 
Solar_FlareCommented:
oops the $ sign should be escaped

\$
0
 
jay-areAuthor Commented:
What is regex and MatchCollection?  It doesn't recognize those.
0
 
Solar_FlareCommented:
Imports System.Text.RegularExpressions
0
 
jay-areAuthor Commented:
Yeah this worked for the most part.  

dim r as new Regex(">\$([0-9|,|.]+)<")
dim mc as MatchCollection = r.matches(htmlstring)
for each m as match in mc
   dim s as string = m.Groups(1).ToString()
   textbox1.text = s
next

When I put in something like TextBox1.text = Textbox1.Text & " " & s, I get every dollar amount on that page.  As it is, I just get the final number from that list that I wanted: Average.  Thanks for your help!
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.