Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1349
  • Last Modified:

Capture screenshot of browser window programmatically

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
trzesniakj
Asked:
trzesniakj
  • 5
  • 4
1 Solution
 
pjedmondCommented:
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
 
trzesniakjAuthor Commented:
Thanks !  I think we're heading in the right direction.

What is VNC ?

Thanks,

John
0
 
trzesniakjAuthor Commented:
How about using something like the Microsoft Web Object (COM Object) or MSHTML object (are they one in the same) ?  

Thanks,

John
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
trzesniakjAuthor Commented:
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
 
pjedmondCommented:
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
 
pjedmondCommented:
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
 
trzesniakjAuthor Commented:
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
 
pjedmondCommented:
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
 
aorenste32Commented:
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
 
trzesniakjAuthor Commented:
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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