|
-
Aug 29th, 2012, 07:05 PM
#1
Thread Starter
Junior Member
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...
-
Aug 30th, 2012, 02:50 PM
#2
Thread Starter
Junior Member
Re: HTTPWEBREQUEST Extract URLS or Links.....
Hellooooooo!!! Hellooooooo!!! Hellooooooo!!! Hellooooooo!!! echo ehco echo!!!
Is anybody there????
-
Aug 30th, 2012, 03:29 PM
#3
Re: HTTPWEBREQUEST Extract URLS or Links.....
This will extract all http:// links from the webpage.
vb.net Code:
Imports System.Text.RegularExpressions Imports System.Net Imports System.Text Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim sb As New StringBuilder Dim html As String Using wc As New WebClient html = wc.DownloadString("http://membersofilluminati.blogspot.nl/") End Using Dim regx As New Regex("http://([\w+?\.\w+])+([a-zA-Z0-9\~\!\@\#\$\%\^\&\*\(\)_\-\=\+\\\/\?\.\:\;\,]*)?", RegexOptions.IgnoreCase) Dim matches As MatchCollection = regx.Matches(html) For Each match As Match In matches sb.AppendLine(match.Value) Next TextBox1.Text = sb.ToString End Sub
-
Aug 30th, 2012, 04:30 PM
#4
Thread Starter
Junior Member
Re: HTTPWEBREQUEST Extract URLS or Links.....
Hey Chris! You're a BOSS! Thanks my friend!!!
 Originally Posted by Chris001
This will extract all http:// links from the webpage.
vb.net Code:
Imports System.Text.RegularExpressions
Imports System.Net
Imports System.Text
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim sb As New StringBuilder
Dim html As String
Using wc As New WebClient
html = wc.DownloadString("http://membersofilluminati.blogspot.nl/")
End Using
Dim regx As New Regex("http://([\w+?\.\w+])+([a-zA-Z0-9\~\!\@\#\$\%\^\&\*\(\)_\-\=\+\\\/\?\.\:\;\,]*)?", RegexOptions.IgnoreCase)
Dim matches As MatchCollection = regx.Matches(html)
For Each match As Match In matches
sb.AppendLine(match.Value)
Next
TextBox1.Text = sb.ToString
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|