How to download source to Text Box without a browser
Is this possible?
Download a webpage source without using a browser and place in to a textbox ready to edit and post(stop page/image load times)
daydie
Junior Poster in Training
68 posts since Jan 2012
Reputation Points: 22
Solved Threads: 0
daydie
Junior Poster in Training
68 posts since Jan 2012
Reputation Points: 22
Solved Threads: 0
You will want to look at the httpwebrequest class and its methods. You can feed it a URL and get back the source (page) to do with as you will. The MSDN articles that come up of you google httpwebrequest will help you.
hericles
Practically a Posting Shark
823 posts since Nov 2007
Reputation Points: 136
Solved Threads: 167
Since already in my code.snippets, see if this helps.:)
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
TextBox1.Text = getCoolHttp("http://www.daniweb.com/members/codeorder/811140")
End Sub
Private Function getCoolHttp(ByVal selCoolUrl As String) As String
Me.Cursor = Cursors.WaitCursor
Try
Dim myResponse As Net.HttpWebResponse = Net.HttpWebRequest.Create(selCoolUrl).GetResponse '// connect.
Dim myStream As IO.Stream = myResponse.GetResponseStream() '// get.
Dim myReader As New IO.StreamReader(myStream) '// read.
Dim webContent As String = myReader.ReadToEnd
myReader.Close() : myStream.Close() : myResponse.Close()
Me.Cursor = Cursors.Default
Return webContent
Catch ex As Exception
Me.Cursor = Cursors.Default
MsgBox("Connection Error.", MsgBoxStyle.Critical)
Return Nothing
End Try
End Function
codeorder
Posting Virtuoso
1,913 posts since Aug 2010
Reputation Points: 255
Solved Threads: 384