This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to save webpage as a image file using PHP?
I would like to create an image on the server using a url string that is given.
I want a screen shot of a website to be created.
Is it possible with PHP GD , if so how ?
Thanks
You need something like PhantomJS to do it. This can be called from PHP.
Pretty sure GD can't handle this by itself. You'd need an HTML renderer too.
As far as I know, there is no existing PHP-Lib, which can do this. PHP-GD has to do with graphics, but you cant do this with it. Even if: What will happen, if the Site uses Javascript to enable certain important parts of a site? Or even images or other resources, that require long running requests? Or consider sites using flash... There are some tools for linux to take screenshots in batch - configurable with timer etc.
Related
This question already has answers here:
How do you parse and process HTML/XML in PHP?
(31 answers)
Closed 7 years ago.
I would like to implement a PHP web page that, given a certain URL, is going to sniff some images from that page.
Do to so, I need :
1) to access the html source-code of that page and find out the URLs of the images I want.
2) to download these images on my FTP
I don't know how to do these two tasks, I guess I will have to use third party libraries, but this is the first time I need to do so and I am not sure.
Any advices ?
Thank you.
This is actually quite a simple task in PHP:
Use file_get_contents() to fetch the HTML from any random page (cURL would work too).
Using DOMDocument, find all img tags inside the page (see getElementsByTagName() method)
Extract the src attribute from each node.
Download the images somewhere with cURL.
Use the FTP functions to upload them to your server (or use a library like this one).
Did you mean grab html page's images and download them and then upload these images to your own FTP server?
If I catch on you correctly, this task will be completed by plain PHP code, no need of third party libraries.
Use preg_match_all to match all images out
Download them(use curl or file_get_content)
upload them to your FTP server, you can simply use curl again, put that image you downloaded above(you don't need save image in your PHP located machine, it is a File Stream in memory) in POST request body then send the request. Or upload image using FTP related functions(find that function in PHP net Document)
You need do step 2 and 3 in a loop basing on data generated from step 1.
Tell me if you need help about them.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Website screenshots using PHP
Can someone tell me how to take a thumbnail off of a web page using php or js without any 'API' support? Otherwise convert HTML to PS and PS to jpeg is also possible.
Thank you.
Try Phantom JS. It can be used to render HTML from the commandline, using various output formats. Creating a thumbnail can be done by setting the zoom factor.
WKHtmlToImage is able to render a webpage using webkit engine. You will have to launch an executable on server-side though.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Website screenshots using PHP
how can i take a screen shot and save it in PHP? I wana take a screen shot a users screen and save it to user's machine when he/she clicks on save button. Is there any way to do this??
You can't do this in PHP.
You could do this using HTML5/Javascript, something like HTML2Canvas does.
Your problem with that would be compatibility with older browsers. So using this would depend on who the website is aimed at.
You have to understand one thing that PHP is a server side script and nothing to do with real time browser needs. You may try JavaScript with some library like jQuery to capture the screenshot. Then you may pass that image via AJAX and there, you can definitely use PHP to save the image into your server directory.
this stackoverflow question may help you.
This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
Website screenshots using PHP
I want to create a script that will show the thumbnail of a site (let's say 400*300px ). I don't want sites like www.bitpixels.com .
So the answear could come in 2 ways:
1) You explain how could I take the screenshot of a website (using only PHP,ajax, etc,... no .NET or other stuff like that :D )
2) You know a website that offers this type of service for free and there's no limitation in the number of thumbs you can get, or their size.
You may want to try wkhtmltopdf (webkit-based html to pdf conversion), it also contains wkhtmltoimage, a version of it that outputs images. It's open source and if you have any sort of dedicated machine you should be able to use it. Otherwise I am not sure. Since it is webkit based it should provide you with a decent rendering of the page too.
Another great tool for this is PhantomJS
This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
Screenshot of current page using PHP
How to convert HTML to image with PHP , have idea!!!
If you have Python, PyQt4 and Webkit installed on your server, you can use Webkit2PNG to do this: it downloads the page, fires up the Webkit rendering engine, and takes a snapshot.
Note that this could be resource-intensive; also, rendering can differ in various browsers (and in IE).
In order to get an image of a web page, you need software that can render a web page (that is, lay out elements, apply styles, and so on). Such software is typically called a "browser".
It's possible to automate a browser from PHP, using COM (like in sAc's answer) on windows, for example.