Search Tools Links Login

Reading a webpage HTML source with the WebBrowser control (and one line of code).


Downloads the HTML source of a webpage using the MS WebBrowser control.

Original Author: m.cap

Inputs

A reference to a MS WebBrowser control

Assumptions

I found many examples about how to download the HTML source of a webpage by means of the Winsock control or the Internet Transfer control, but not with the WebBrowser control. The Winsock control is too complex to me, and the Internet Transfer didn't work for me with pages larger than 5 Kb or so. I've found a one-line code that seems to work properly.
I'm a sort of a newbie about this topic, so please be patient. I'm posting it just to share something that I found useful.

Returns

A string containing the HTML source of the web page

Code

After navigating to the desired webpage, execute the following line:
myTextBox.Text = myWebBrowser.Document.documentElement.innerHTML

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 81 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.