Jump to content

Taking Screenshots of Website?


chaseman

Recommended Posts

Just asking out of curiosity, if I had a script where the user can enter a domain from the web and I wanted to take an automated screenshot of that website, how could I accomplish this?

 

I've seen this on other websites before, how are those automated screenshots taken? Is it difficult to do, are there pre-written scripts I could use?

Link to comment
Share on other sites

Basically I think all you need is this:

http://phpsnips.com/snippet.php?id=61[

 

I think a way simpler than any rendering engine :D

 

This grabs an image from a remote website, not an image of the webpage. You have read it wrong.

 

To take a screenshot of a webpage to generate a thumbnail is not possible with PHP alone. You could use PHP to collate the urls of which you need screen grabs, however the actual job of doing the screen grab will need to be that of a desktop application, basically a web browser. There maybe some plugin for Firefox that can do this and you can feed data into it, I don't know, however I do know that what you are after cannot be done without a linux or windows desktop.

 

Alexa used to offer it's thumbnail service however I don't know if they do that any more, you will have to check.

Link to comment
Share on other sites

  • 2 weeks later...

To take a screenshot of a webpage to generate a thumbnail is not possible with PHP alone. You could use PHP to collate the urls of which you need screen grabs, however the actual job of doing the screen grab will need to be that of a desktop application, basically a web browser. There maybe some plugin for Firefox that can do this and you can feed data into it, I don't know, however I do know that what you are after cannot be done without a linux or windows desktop.

 

 

Will this do it:

http://www.mysql-apache-php.com/website_screenshot.htm

 

I am also wanting to do something similar....

 

Is this correct thinking...

1 > Client sends a URL to the server

2 > php then grabs the URL and send this to the appropriate program

3 > the program then grabs a screenshot of the URL and saves in a bin somewhere on the server.

 

I'm assuming this cannot really be done on any shared hosting and a dedicated server would be needed? Has anyone else had any experience with this?

Link to comment
Share on other sites

 

Yes, this collection of programs can perform the task, and the instructions are clear.

 

I'm assuming this cannot really be done on any shared hosting and a dedicated server would be needed?

This will not be possible on any shared host that I know of, in fact I can also rule out hosted dedicated servers. You need linux running the X Windows environment such as Gnome or KDE (basically the desktop). You are better setting up your own in-house Linux machine.

Link to comment
Share on other sites

This will not be possible on any shared host that I know of, in fact I can also rule out hosted dedicated servers. You need linux running the X Windows environment such as Gnome or KDE (basically the desktop). You are better setting up your own in-house Linux machine.

 

IPN scripts do not work when on a shared server as 'fsockopen' is usually forbidden for security reasons (so i found out the hard way)... but i was under the impression that if i hired a dedicated server like this, you were given free reign on what programs to install and ports to use... etc? So i'm not sure how this wouldn't work on one? Have you had experience in attempting this yourself?

Link to comment
Share on other sites

ut i was under the impression that if i hired a dedicated server like this, you were given free reign on what programs to install and ports to use... etc So i'm not sure how this wouldn't work on one?

 

Because hosted servers are not installed with X Windows. Usually you SSH into a hosted server. They do not have a desktop environment, only a command line. The requirements on the link you posted are:

 

Linux Server with Centos/RHEL
Khtml2Png (http://khtml2png.sourceforge.net)
ImageMagick (http://imagemagick.org)
KDE Desktop Environment
Cmake - http://www.cmake.org

 

The 4th in the list is KDE. This is a desktop just like Microsoft Windows. The reason that a desktop is needed is so that the web browser can print the screen of the websites it visits. Here is the line to install the browser

yum install firefox

.

 

You can look into hosted servers with X Windows but I have never come across them. I maybe wrong but I don't know. Essentially a server should not have a desktop, i.e a web server.

 

It is far better to get a cheap pc and install Linux on it than paying for a server anyway. If you do this on your own Linux machine, the screenshots that are created can be FTP'd to the web server as an automated routine.

 

Have you had experience in attempting this yourself?

Yes. I have done this with a MS Windows machine. The urls to visit come from an XML feed on the web server to a program that runs macros to control firefox, then using a screen grab plugin it can save the desktop image. The images are then transferred to the web server overnight where image magic runs to crop them to size.

 

This was something I did a long time ago.

Link to comment
Share on other sites

I am kind of confused, my post here got deleted. I am not sure if it was because someone deleted it for some reason, or if it was because PHPFreaks was done earlier, perhaps some data was lost.

 

Anyway, to repeat what I had put into my original post.

 

There is an easy way to do what you are wanting. I did some digging on Google after reading your post here, and I found this:

http://www.webshotspro.com/ You can go here and use Curl to get the screenshots.  Just enter the URL, and then get the image.

The official way to do it however, would be to use their API. Just sign up for an account, and you can utilize their API to do what you are wanting.

 

Alternatively, here are some other options as well: http://mashable.com/2007/08/24/web-screenshots/

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.