• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 203
  • Last Modified:

fetch source code from site

Hi,

Is there a way to read the sourcecode of a site using the Internet Control Webbrowser ?
I would do it with just the raw sock, but I have to login to see that page. And I have no idea how I can save the session or cookies. So I'm trying it just with the internet control.

I have to read some info from the members area, that's why I need to get the sourcecode via that control. Anyone knows how ?
0
Reggie_BE
Asked:
Reggie_BE
  • 3
1 Solution
 
ericl1stCommented:
Assuming your webbrowser control is named WebBrowser1, use the following:

To get the complete HTML for a page:
WebBrowser1.Document.documentElement.outerhtml

To get everything between the <html> tags:
WebBrowser1.Document.documentElement.innerhtml

To get everything between the body tags, including the body tags:
WebBrowser1.Document.body.outerhtml

To get everything between the body tags, without the body tags:
WebBrowser1.Document.documentElement.outerhtml

To get just the text on the page:
WebBrowser1.Document.body.innertext

Cheers!
0
 
ericl1stCommented:
Sorry, I mistyped the "To get everything between the body tags, without the body tags". It should read:

WebBrowser1.Document.body.innerhtml

Cheers!
0
 
Reggie_BEAuthor Commented:
Do I have to do something special before those lines ?
I tried

WEB.Navigate "http://wwww.reggie.be"
MsgBox WEB.Document.documentElement.outerhtml

but it gives an error: Object Variable or With Block variable not set.
I'm using VB 6.0
0
 
ericl1stCommented:
The problem is that you can't have the "WEB.Navigate" command and the second command right after each other because the page can't load that quickly. Either put the code "MsgBox WEB.Document.documentElement.outerhtml" in a command button and click it after the page loads, or in either the "WEB_DocumentComplete" event (to show the message box after the page is displayed) or "WEB_NavigateComplete2" event (to show the message box after the page loads but before it is displayed).

Cheers!
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now