dcole.ath.cx Posted July 8, 2006 Share Posted July 8, 2006 Is there a way php can take snapshot of a webpage? Link to comment Share on other sites More sharing options...
reportingsjr Posted July 8, 2006 Share Posted July 8, 2006 No, I think the closest thing to this would be like javascripts window print function.Why would you need this anyways? Im sure you could use the gd library with variables and such to acheive what you want. Link to comment Share on other sites More sharing options...
mikemanx2 Posted August 2, 2006 Share Posted August 2, 2006 or you can just do the Ctrl alt Print Screen buttons open up paint and do ctrl v Link to comment Share on other sites More sharing options...
justsomeguy Posted August 2, 2006 Share Posted August 2, 2006 That's true, but you can't tell PHP to press ctrl-alt-prtscn, or any other key combination for that matter. Not to mention that paint isn't installed on a Linux server, or that the specific keystrokes are for Windows only.He was asking how to use PHP to generate an image of a rendered web page (to dynamically create thumbnails of pages for a search engine). The answer, before the posts got deleted, was that a rendering engine needs to be used to render the page and save it, and I'm sure there are several programs available to do that, but not necessarily for free. But you can always use Firefox's Gecko engine and write your own program to save the rendering as an image I guess. Link to comment Share on other sites More sharing options...
The Reverend Posted August 2, 2006 Share Posted August 2, 2006 Depends on what you want it to do with the webpage. You can have it read the page and do something with what it read. What is the purpose of reading it in your case? Link to comment Share on other sites More sharing options...
justsomeguy Posted August 2, 2006 Share Posted August 2, 2006 He was working on a search engine at the time, I believe he just wanted to show a small thumbnail next to each result. I don't think there was any OCR or anything involved (which would be pointless anyway). Link to comment Share on other sites More sharing options...
dcole.ath.cx Posted August 2, 2006 Author Share Posted August 2, 2006 It was for my search engine... Justsome guy, what where you talking about before where a php function could find from start to a point, then from that point to another until it reaches the end of a string. For finding words in () or before and after ORs and ANDs.. Link to comment Share on other sites More sharing options...
justsomeguy Posted August 2, 2006 Share Posted August 2, 2006 Hmm.. it's been a couple weeks.. I think it had something to do with using strtok to tokenize a string.http://www.php.net/manual/en/function.strtok.php Link to comment Share on other sites More sharing options...
reportingsjr Posted August 3, 2006 Share Posted August 3, 2006 Could you use the split function to put it into an array? And what you probably want to do is use the gd library, which is a library that allows you to create custom images by putting strings of text and colors onto it.So what you could probably do is this, look up all the dodad on the gd library and hw to create images, then make it so you can put php in a .gif or some extension like that.. then I beleive there is a highlight page function or something that can pull the source code of a page so you might be able to just put html on the image and it will automatically look like that page. so for the thumbnail you would put this:<img src="render.gif?site=http://w3schools.com" />, I think you know what to do for the rest now Link to comment Share on other sites More sharing options...
justsomeguy Posted August 3, 2006 Share Posted August 3, 2006 That wouldn't work so automatically like that. You can write whatever text you want to an image, if you want to use source code or whatever to put in the image you can do that (the highlight function, BTW, highlights PHP source, not HTML), but the image will show the code itself. At that point it is an image of code. Which might be handy if you don't want people to be able to directly copy and paste, they would have to write it themselves.But you can't render the HTML. The browser, not PHP, renders the HTML, and the browser is not involved in creating the image, only PHP is. Different browsers do different things with HTML because each of them use their own rendering engine (except for Netscrape, which uses the Gecko engine from Mozilla). So you can't create a page render from HTML source without using a rendering engine, and PHP does not have any use for one. Link to comment Share on other sites More sharing options...
reportingsjr Posted August 3, 2006 Share Posted August 3, 2006 d'oh! what was I thinking lol. and the highlight function I tried gives the source code.. what exactly is the syntax for that function? Link to comment Share on other sites More sharing options...
justsomeguy Posted August 3, 2006 Share Posted August 3, 2006 You can use highlight_file or highlight_string:http://www.php.net/manual/en/function.highlight-file.phphttp://www.php.net/manual/en/function.highlight-string.phpFor example, highlight_file(__FILE__) will highlight the current file, which is good for making self-describing examples:http://manchine.net/w3/array.php Link to comment Share on other sites More sharing options...
reportingsjr Posted August 3, 2006 Share Posted August 3, 2006 Ah yes, the highlight_file one is what I tried out. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now