Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42220

Fail to get Text from a WebPage using (Httpwebrequest), Anyone to Fix my code?

$
0
0
Hi All, I am trying to get the TAGS from a website using Httpwebrequest, even tho I got some help from an amazing friend, yet I kee failing. I on day 3 now and I am exhausted... I really hope I could get some hand with this, Thank you Very much in advance..

Below is the HTML WebPage Code that I was talking about, I need the Tags in Red Color into a ListBox or ListView.

Code:

<div CLASS="sidebar_head">Favorit Tags</div>
        <div CLASS="sidebar_comments">            <A HREF="http://www.searchmusic.com/tags/12/?search=tag&tag=All Kinds of Music">All Kinds of Music</A>&nbsp;&nbsp;
                        <A HREF="http://www.SITE.com/tags/12/?search=tag&tag=HipHop">HipHop</A>&nbsp;&nbsp;
                        <A HREF="http://www.SITE.com/tags/12/?search=tag&tag=EUROPE and US Charts">EUROPE and US Charts</A>&nbsp;&nbsp;
                        <A HREF="http://www.SITE.com/tags/12/?search=tag&tag=Rap">Rap</A>&nbsp;&nbsp;
                        <A HREF="http://www.SITE.com/tags/12/?search=tag&tag=Rock">Rock</A>&nbsp;&nbsp;
    </div>

So far I have tried everything, and below is my httpwebrequet code:
PHP Code:

  Private Sub GetTags(ByVal Username As String)
        Try
            
Dim Webreq As HttpWebRequest HttpWebRequest.Create("http://www.Site.com")
            
Using Webres As HttpWebResponse Webreq.GetResponse
                Using Reader 
As New StreamReader(Webres.GetResponseStream)
                    
Using Rich As New RichTextBox With {.Text Reader.ReadToEnd}
                        For 
As Integer 0 To Rich.Lines.Count 1
                            Dim line 
As String Rich.Lines(i)
                            If 
line.Contains("<div CLASS=" Chr(34) & "sidebar_comments" Chr(34)) Then
                                Dim Num 
As Integer 3
                                
Do Until Rich.Lines(Num).Contains("</A>")
                                    
ListView1.Items.Add(GetBetween(Rich.Lines(Num), "</A>"Chr(34), 1))
                                    
Num += 1
                                Loop
                                
Exit Sub
                            End 
If
                        
Next
                    End Using
                End Using
            End Using
        
Catch ex As Exception
            ListView1
.Items.Add("None!")
        
End Try
    
End Sub 

Cant wait to get a response..... Thanks a lot

Viewing all articles
Browse latest Browse all 42220

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>