Solved

Capture screenshot of browser window programmatically

Posted on 2004-08-13
10
1,332 Views
Last Modified: 2011-09-20
Hi there,

I know there are ways and apps to capture how a browser displays a webpage interactively meaning that you, as a user, need to fire up an app and do something to capture the way the page looks now.

But I would like to know how you can do that same thing programmatically (without a user interacting with it) with Visual C#.NET or VB.NET.  What I'm looking to do is give a URL to a program and basically, have it take an image snapshot of the way that webpage (the entire page even if you would normally have to scroll down to see the entire thing) looks now, and dump that image to a file (GIF, JPG, TGA, whatever).

Also, if there are libraries of objects out there to help with this, please let me know.  Any help would be appreciated.

Thanks,

John
0
Comment
Question by:trzesniakj
[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
  • 5
  • 4
10 Comments
 
LVL 22

Expert Comment

by:pjedmond
ID: 11797898
The obvious approaches that I can think of:

1.    Sent the {Alt}{PrtSc} command to get it copied to clipboard.
2.    Take the output from VNC or similar and use that (source code already available)

won't work because you need to scroll down the screen for large pages...UNLESS you make sure that you have a huge screen.

Also, it seems a pity that as the page is already coded so neatly (in HTML), then why should we want to convert it....however......this site seems to list most of what you might be looking for:

http://www.w3.org/Tools/html2things.html

Remember that to get to the format that you want, you might need to go through a number of different filters.

A possible route to get to a tiff file would be to convert to PS, using a PS printer to a file, and then use ghostview to convert the output to a tiff or indeed a pdf file.

If you get as far as a tiff file, then there are loads of convertion tools already in existance that convert tiff to most other graphics formats - key area to look here is relating to faxes that tend to use tiff type image manipulation processes.
0
 

Author Comment

by:trzesniakj
ID: 11802268
Thanks !  I think we're heading in the right direction.

What is VNC ?

Thanks,

John
0
 

Author Comment

by:trzesniakj
ID: 11802418
How about using something like the Microsoft Web Object (COM Object) or MSHTML object (are they one in the same) ?  

Thanks,

John
0
What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

 

Author Comment

by:trzesniakj
ID: 11802567
In lieu of taking a "screen shot" of a site, I might be able to get by with what website capture apps (like Leech) do...capture a page and all the images on that page.  Can anyone think of a way to do that in VB.NET ?

Another thing I just remembered...in VB6, there was an object called the "Inet" object.  It allowed you to put a URL in it and get the HTML back from that site.  Is there something like that now in VB.NET ?

Thanks,

John
0
 
LVL 22

Expert Comment

by:pjedmond
ID: 11803341
VNC is actually a remote control progam that displays a copy of the machine on a window on the remote machine. Source code is available. There are a number of derivatives of this:

http://www.realvnc.com/
http://www.tightvnc.com/
http://ultravnc.sourceforge.net/

All are variants on the same code.
0
 
LVL 22

Accepted Solution

by:
pjedmond earned 350 total points
ID: 11803347
There is a command in linux called 'wget' that can be configured to read in all of a web page and associated picture files that go with it. Again all source code is available and it exists in windows form as well:

http://www.interlog.com/~tcharron/wgetwin.html

In fact it can be configured to be recursive like leech. (Just trying to prevent you reinventing the wheel.)

0
 

Author Comment

by:trzesniakj
ID: 11804595
OK.  We're on the right track here !  

I DL'd wget as per your suggestion.  I installed and configured it as well as DL's a simple GUI interface for it.  Initial tests work fine.  I was able to recursively get 2 levels of a test website.  But the reason I want to learn about taking an image snapshot of each page is that all the pages and images just from the first 2 levels of the files for the site was a total of 22 Mb.

Obviously normal for websites.  But for my application, I just need a picture of what each page looked like.  That will save an incredible amount of space too.

Any other suggestions going back to the original request of taking an image of a webpage ?

Thanks !

John
0
 
LVL 22

Expert Comment

by:pjedmond
ID: 11804936
The last thing that I can think of that is of any use, is that by using wget to index the list of pages into a file, and then using that file as a template, and using {send keys} to open up internet explorer at each page, and print the page through a postscript printer. This approach causes problems as the process is automatic, and if something goes wrong the send keys continues regardless.

As a linux, rather than a windows programmer, I'm afraid that I can't help any further.
0
 
LVL 1

Expert Comment

by:aorenste32
ID: 11810804
If it were me I'd download the source to mozilla (www.mozilla.org/download-mozilla.html).  I haven't looked at it myself, but from what I understand, there are many options in the source code and you can set it up to be an HTML rendering engine that you can just link your program against.
0
 

Author Comment

by:trzesniakj
ID: 11830282
Actually, I found out that the app I normally use for interactive screen caprutes actually has a COM server for it.  

So now we have the ability to programmatically do anything with it that you can do interactively.

Although, if I were to need to DL an entire website, I'd certainly dig into wgetwin more.

Thanks,

John
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

A short article about problems I had with the new location API and permissions in Marshmallow
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

707 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