Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to save a web page with VB

Status
Not open for further replies.

FrankFrankel

Technical User
Nov 6, 2010
5
CA
Hi,

I've seen numerous methods on how to save a web page with vb, but I'm stumped. Every time I try the methods described using the MSXML object I only get part of the page. When I view the page in a web browser there is a whole lot more. I suspect I'm downloading the page right from the server before it is processed into HTML for my browser to read.

Does anyone know how I can code something to go to a web site and then save the web page that is displayed in web browser and save it to a text file or something. I can't seem to find any code snippets to get me started in the right direction.

 
OK, I've been hunting the net and found articles on DOM and using the IE object to call web pages. I'm able to get the IE object to work, but I haven't been able to get the DOM stuff to work.

I found a Microsoft MSDN page that helped steer me in the right direction on how to automate IE.


Now all I have to do is figure how to save a web page with DOM. Would anyone know if there are any code snippets and an accompanying tutorial on DOM floating around Tek Tips?
 
Hi Frank,

check out this thread: thread222-1616585
Scroll down to my last code post.
That should get you the source of the website. all you have to do then is to save it to a properly encoded text file.

Cheers,
MiS

[navy]"We had to turn off that service to comply with the CDA Bill."[/navy]
- The Bastard Operator From Hell
 
Also keep in mind that many pages contain scripts or other functions which are usually saved in another location. If this is the case, it would also explain why only part of your page is saved as it doesn't have access to everything located in the source file.

If at first you don't succeed, then sky diving wasn't meant for you!
 
Seconded.
If you need the full pages, i.e. browsable copies with all required files, you should get a webspider software for that.

I can recommend "Teleport Pro". You can get a free trial here:

It's not that expensive. There are also freeware webspiders, but I don't know how reliable or complete their functions are.



[navy]"We had to turn off that service to comply with the CDA Bill."[/navy]
- The Bastard Operator From Hell
 
Hi Guys

I tried your suggestions and it gives me what I've been getting already. Just the file from the server. I don't want to down load the file from the server. I want to save the page that is displayed on my end in the web browser.

I already have a code snippet that works to download the web page from the server. It is this

Dim xml As Object ' MSXML2.XMLHTTP

Set xml = GetMSXML

' grab webpage
With xml
.Open "GET", URL, False
.Send
End With

GetWebpage = xml.responseText

End Function

Getting a a piece of software that is dedicated to web crawling is not what I need. All I need to do is save a web page that I can see using the automation in VBA. I want to use the IE object go to a web site and save the resulting web page and mayvbe use the DOM object to get some info.
 
Perhaps you could give us the URL you are trying to work against so we can see what is happening.

>I already have a code snippet that works to download the web page from the server

So are you saying the problem is now fixed?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top