Solved

Capture screenshot of browser window programmatically

Posted on 2004-08-13
10
1,317 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
  • 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
 

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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
wefewf 2 43
mergeTwo  challenge 13 72
Path of Workbook 3 45
Controlled Assessment GCSE - desperate help needed 4 53
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
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 …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

758 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now