?
Solved

fetch source code from site

Posted on 2003-03-22
4
Medium Priority
?
200 Views
Last Modified: 2013-12-25
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
Comment
Question by:Reggie_BE
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 1

Accepted Solution

by:
ericl1st earned 800 total points
ID: 8188867
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
 
LVL 1

Expert Comment

by:ericl1st
ID: 8188869
Sorry, I mistyped the "To get everything between the body tags, without the body tags". It should read:

WebBrowser1.Document.body.innerhtml

Cheers!
0
 

Author Comment

by:Reggie_BE
ID: 8189583
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
 
LVL 1

Expert Comment

by:ericl1st
ID: 8189780
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month11 days, 11 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question