Just wondering if it's possible to screen grab a page you are viewing with a PHP script or javascript? For example, load up a page in an iframe and then save that view as a JPEG?
I'm sure it's possible somehow, but are there any known implementations/libraries that help out?
Nope, sorry, it is impossible with Javascript and definitely impossible with a server-side language like PHP. (Edit: I mean it's impossible to take a screenshot of the user's view of the page.)
It depends on what you want to do this for, but you might want to find a script or program that runs server-side and renders the webpage there. But if you really want to take the screenshot of the user's view of the page, it's pretty much impossible.
http://html2canvas.hertzen.com/ might do the trick.
There is a python tool called Webkit2png, hope it helps. But in PHP, i don't believe its possible
You can't do it in JS but you could do something similiar server side if you know the url of the page you want to convert to an image.
Tools like khtml2png could be called from php to render the page.
Possible with the GD2 extension and some knowledge of the internals you are capturing - read here for an example.
Thanks for the help guys. I did find this interesting resource:
http://www.zubrag.com/scripts/website-thumbnail-generator.php
It's not PHP specific by any means, just an example of running an EXE script that is called by PHP. Needs a windows server I believe though.
Related
i was viewing this video and i really want to develop this is PHP with no AJAX, do you how to start? where can i find some examples codes? Thanks.
Live "streaming" without AJAX could be done in PHP using ob_flush/flush, ergo output buffering. But that's usually pretty dirty and unwanted. However, what you see in that video is only possible with Javascript/"AJAX" (or Flash and similar plugins).
Hello, i was viewing this video and i
really want to develop this is PHP
with no AJAX, do you how to start?
There is no way to start as that functionality requires Ajax. Your hole is a square, why not use the square peg (Ajax).
is there any way to see the functions that are called after pushing a link or a button in a web page done with PHP?
I user Firefox.
Regards
Javi
Not exactly sure what you're trying to achieve but you could install/configure a debugger module like xdebug.
Then you can either step through the code or use the profiler to see which functions have been hit (and how long they took).
It it's your own code, open it in the editor.
If it's someone's else code, there is no way.
I've tried searching everywhere but there's seems to be no implementation available other than having the client use a file (batch/exe of some sort).
You just can't do it. PHP is server side scripting language, maybe you can do that using JavaScript, but I'm not even sure about that.
I know someone implemented such service, but actually he had to use Mozilla browser, which opened, a script (I think it was not JS, maybe perl, c/c++) made a screenshot and uploaded it.
I'm assuming you mean "your" in the general sense. If you mean "how does one take a screenshot...", you generally hit the print screen key. If you're trying to capture your users' browser output, I'd say that it's probably not possible. If it were, the best you could get is the output of what you wrote yourself.
Google Gears might be hackable to do something close, if you can simulate the print screen key press with JS and get the file to save somewhere gears can access.
You can't do that in PHP, as PHP is running on the server, and not the client.
To get screenshots of the browser, you can take a look at, for instance, this list.
If you are look for an automated solution to take screenshot of web pages opened in a browser window, you could also look at this question : How to capture x screen using PHP, shell_exe and scrot and it's answers.
And, finally, and without selecting any particular post, you can try a search on SO ; something like screenshot browser, sorted by relevance, seems to get some interesting posts :-)
Good luck !
I am trying to find a PHP script (or a script in a different language) that after passing a URL, it takes a screenshot of the website for that URL. So for example if I pass stackoverflow.com, it should take a screen shot of the website (in this case the homepage), keep it on the server, and provide a link to that pic.
Is there an easy way to do that?
I know it is possible because that's how they take thumbnails for websites in Alexa for example.
If you need more explanation of what I mean please just post a comment and I will explain more.
Thank you :)
Start a Browser (like system("firefox [url]")), run a screengrabber for that window and save the image somewhere.
Since the output is always depending on the render engine used it is not possible by using php alone.
Other option would be to embed a rendering engine (Gecko or similar) into your php script.
You can use browsershots.org service or litmusapp.com.
Both of these will generate screenshot of a page. You can then download the screenshot and use it in a way you need to.
Something like Litmus?
Browsershots normally has their backend source code available, but as of this answer, it appears to be offline at the moment. There is an outdated mirror on Github which you can look at.
I am dealing with a problem where I need to do few thing at the SERVER SIDE using JAVASCRIPT (I am using php + apache combination )-
read source of url using curl
run it through some server side JavaScript and get DOM out of it
traverse and parse the DOM using pre-existing java script code.This code works fine in a browser.
I goggled and found http://pecl.php.net/package/spidermonkey , which allows us to run java script at server.is there any better way to achieve this? can we use Mozilla engine to get DOM out of HTML source code and process it using java script ?
Thanks in advance
You can check Jaxer.org, where you tell your javascript where to run.
alt text http://jaxer.org/images//Picture+4_0.png
hope it helps, Sinan.
PHP contains a DOM parser - I would recommend using this to achieve the same results, rather than using server-side Javascript.
You might want to use something else than Javascript, but if you really need this, you can run firefox under Xvfb and remote connect to it from php. It's not exactly trivial to set up, but it's possible.
You might want to try with something like SimpleBrowser instead.
You might want to try installing GromJS. But the success depends on complexity of your JS code. As far as I see, GromJS does not have DOM :(
A lot more complex project, Narwhal does have DOM and a lot more.
For more information, refer to Mozilla hub about ServerJS.