chaseman Posted July 11, 2011 Share Posted July 11, 2011 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? Quote Link to comment Share on other sites More sharing options...
thehippy Posted July 11, 2011 Share Posted July 11, 2011 You would need a HTML rendering engine (ex. Gecko, WebKit being OSS) to render the page then you would need to convert the render into an image format. Something already exists for doing such a thing, CutyCapt Quote Link to comment Share on other sites More sharing options...
makuc Posted July 11, 2011 Share Posted July 11, 2011 Basically I think all you need is this: http://phpsnips.com/snippet.php?id=61[ I think a way simpler than any rendering engine Quote Link to comment Share on other sites More sharing options...
JonnoTheDev Posted July 11, 2011 Share Posted July 11, 2011 Basically I think all you need is this: http://phpsnips.com/snippet.php?id=61[ I think a way simpler than any rendering engine 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. Quote Link to comment Share on other sites More sharing options...
freelance84 Posted July 21, 2011 Share Posted July 21, 2011 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? Quote Link to comment Share on other sites More sharing options...
JonnoTheDev Posted July 21, 2011 Share Posted July 21, 2011 Will this do it: http://www.mysql-apache-php.com/website_screenshot.htm 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. Quote Link to comment Share on other sites More sharing options...
freelance84 Posted July 21, 2011 Share Posted July 21, 2011 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? Quote Link to comment Share on other sites More sharing options...
JonnoTheDev Posted July 21, 2011 Share Posted July 21, 2011 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. Quote Link to comment Share on other sites More sharing options...
JonnoTheDev Posted July 21, 2011 Share Posted July 21, 2011 Reading that website a bit more it uses a virtual display, so essentially it maybe possible on a dedicated server, however I would not want to put this on my live webserver. I would still prefer to use a machine at home or in the office. Quote Link to comment Share on other sites More sharing options...
freelance84 Posted July 22, 2011 Share Posted July 22, 2011 Ok, well, thanks for the heads up... Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted July 25, 2011 Share Posted July 25, 2011 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/ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.