Results 1 to 4 of 4

Thread: HTTPWEBREQUEST Extract URLS or Links.....

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2012
    Posts
    18

    Lightbulb HTTPWEBREQUEST Extract URLS or Links.....

    I would like to use the httpwebrequest to pull all the links from my blog. I would like for the links to be extracted and sent to a textbox1.text from the httpwebrequest method.

    Here's the example that I have to extract all the html source code, but all I need is the URLs from my web page:

    Try
    TextBox1.Text = ""
    Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("http://membersofilluminati.blogspot.com/")
    Dim response As System.Net.HttpWebResponse = request.GetResponse()
    Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream())
    Dim sourcecode As String = sr.ReadToEnd()
    TextBox1.Text = sourcecode
    Catch ex As Exception
    End Try


    Could someone please show me how to convert this to extract/parse only links or URLs from the web page and send it to Textbox1.text???


    Thanks...

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Jun 2012
    Posts
    18

    Question Re: HTTPWEBREQUEST Extract URLS or Links.....

    Hellooooooo!!! Hellooooooo!!! Hellooooooo!!! Hellooooooo!!! echo ehco echo!!!

    Is anybody there????

  3. #3
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Re: HTTPWEBREQUEST Extract URLS or Links.....

    This will extract all http:// links from the webpage.

    vb.net Code:
    1. Imports System.Text.RegularExpressions
    2. Imports System.Net
    3. Imports System.Text
    4.  
    5.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    6.         Dim sb As New StringBuilder
    7.         Dim html As String
    8.  
    9.         Using wc As New WebClient
    10.             html = wc.DownloadString("http://membersofilluminati.blogspot.nl/")
    11.         End Using
    12.  
    13.         Dim regx As New Regex("http://([\w+?\.\w+])+([a-zA-Z0-9\~\!\@\#\$\%\^\&\*\(\)_\-\=\+\\\/\?\.\:\;\,]*)?", RegexOptions.IgnoreCase)
    14.         Dim matches As MatchCollection = regx.Matches(html)
    15.  
    16.         For Each match As Match In matches
    17.             sb.AppendLine(match.Value)
    18.         Next
    19.  
    20.         TextBox1.Text = sb.ToString
    21.     End Sub

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Jun 2012
    Posts
    18

    Re: HTTPWEBREQUEST Extract URLS or Links.....

    Hey Chris! You're a BOSS! Thanks my friend!!!



    Quote Originally Posted by Chris001 View Post
    This will extract all http:// links from the webpage.

    vb.net Code:
    1. Imports System.Text.RegularExpressions
    2. Imports System.Net
    3. Imports System.Text
    4.  
    5.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    6.         Dim sb As New StringBuilder
    7.         Dim html As String
    8.  
    9.         Using wc As New WebClient
    10.             html = wc.DownloadString("http://membersofilluminati.blogspot.nl/")
    11.         End Using
    12.  
    13.         Dim regx As New Regex("http://([\w+?\.\w+])+([a-zA-Z0-9\~\!\@\#\$\%\^\&\*\(\)_\-\=\+\\\/\?\.\:\;\,]*)?", RegexOptions.IgnoreCase)
    14.         Dim matches As MatchCollection = regx.Matches(html)
    15.  
    16.         For Each match As Match In matches
    17.             sb.AppendLine(match.Value)
    18.         Next
    19.  
    20.         TextBox1.Text = sb.ToString
    21.     End Sub

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width