p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Visual Basic 2005 Basics (http://p2p.wrox.com/forumdisplay.php?f=137)
-   -   Trying to pull data between two different HTML tag (http://p2p.wrox.com/showthread.php?t=65740)

boniggy February 6th, 2008 02:36 AM

Trying to pull data between two different HTML tag
 
Ok so im a complete n00b at using vb.NET as i have been used to using
vb6 for a little over a year. I'm sort of forcing myself to
learn .NET.

Anyways im working on a project that parses a webpage of its data. The
data I need to pull is between the tags of <div class="description">
and </ul>. If i could pull this data it would be great. The only
problem i have is that my program currently starts at the first
"description" tag and then parses everything else in to the bottom of
the page. I cant seem to figure out why it wont stop at the last </ul>
tag.

Here is the code for the portion im talking about:

Code:

            'get the response from the server
            responseReader = New IO.StreamReader(webRequest.GetResponse.GetResponseStream)
            responseData = responseReader.ReadToEnd
            responseReader.Close()
            strData = responseData

            Dim intIndex As Integer
            Dim intLastIndex As Integer
            Dim strInfo As String
            strInfo = ""
            intIndex = strData.IndexOf("<div class=""description""",
0)
            intLastIndex = intIndex

            While intIndex >= 0

                intIndex = strData.IndexOf("</ul>", intIndex)

                If intIndex >= 0 Then
                    strInfo += strData.Substring(intLastIndex,
intIndex - intLastIndex) + "</ul>"
                    intLastIndex = intIndex
                    intIndex = strData.IndexOf("<div
class=""description""", intLastIndex + 1)
                Else
                    intIndex = -1
                End If
            End While

I then take the data that gets parsed and put it into a txt or html
file. Personally i think it might be ReadToEnd at the top of the
 code.
If i've left anything out that you need please let me know. Like
i said im still learning programming so if its too cryptic I may
answer back with an explanation.

Any help would be GREATLY appreciated and thank in advance!

-Boniggy



All times are GMT -4. The time now is 05:12 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.