Closed Thread Icon

Topic awaiting preservation: Screen Capture (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=26318" title="Pages that link to Topic awaiting preservation: Screen Capture (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Screen Capture <span class="small">(Page 1 of 1)</span>\

 
AT
Bipolar (III) Inmate

From: Gainesboro, TN, USA
Insane since: Aug 2000

posted posted 07-24-2005 06:22

Is there a way to have a PHP script take an URL and capture the look of the site?

Thanks

Casey / AT
Personal
Song Lyrics
Family Recipes

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

posted posted 07-24-2005 11:26

Not really, since what you want is the result produced the rendering engine of the browser which is obviously on Client Side and out of reach of a Server Side language. However, depending on what you really want to do, if it's a one shot usage, you could have a look at Rendering Web Page To Images using the canvas element that has recently been implemented in Gecko 1.8. It means that you must use either Deer Park ( the alpha previews of FireFox 1.1 or 1.5 ), or probably Mozilla 1.8b2.

Hope that helps,

reisio
Paranoid (IV) Inmate

From: Florida
Insane since: Mar 2005

posted posted 07-24-2005 11:55
quote:
AT said:

Is there a way to have a PHP script take an URL and capture the look of the site?


Yes, of course. Just have to open a decent browser and take a screenshot.

AT
Bipolar (III) Inmate

From: Gainesboro, TN, USA
Insane since: Aug 2000

posted posted 07-24-2005 22:07

Thanks poi Always helpful.

reisio, the way you even phrased your answer was wrong. Why waste your time on what apparently is such a stupid question? Nah, don't answer. You might have someone else you need to bug. Shoo now.

later

Casey / AT
Personal
Song Lyrics
Family Recipes

WarMage
Maniac (V) Mad Scientist

From: Rochester, New York, USA
Insane since: May 2000

posted posted 07-25-2005 01:42

It is not really PHP but I don't think you would have found a nice solution to do this with PHP it is just not the direction PHP travels in. PHP is more server side and this is a clientside thing.

I do have a solution if you are willing to use python, and are running windows. If you need to do this on the server you are going to run into some complication, and I really wish you the best of luck with that.

You were pretty vague with your requirements so I hope this fits the build.

You will need to download and install I would say to get the 2.4 stuff python, win32com and PIL for the screenshots.

code:
import ImageGrab
from win32com.client import Dispatch
from time import sleep

page = "http://www.google.com"
file = "C:\\test.jpg"

ie = Dispatch("InternetExplorer.Application")
ie.Visible = 1
ie.Navigate(page)
if ie.Busy:
	sleep(2)

ImageGrab.grab().save(file)



There is a known bug with the code above. If you have dual monitors you will have to make sure IE launches in your main monitor window, ImageGrab.grab() doesn't grab the content in both monitors.

Dan @ Code Town

(Edited by WarMage on 07-25-2005 01:43)

reisio
Paranoid (IV) Inmate

From: Florida
Insane since: Mar 2005

posted posted 07-25-2005 04:46
quote:
AT said:

the way you even phrased your answer was wrong. Why waste yourtime on what apparently is such a stupid question? Nah, don't answer. You might have someone else you need to bug. Shoo now.


Not sure what to make of that.

http://us2.php.net/manual/en/function.exec.php

As an example, on my box all I would have to run is these two commands:

Then I'd have a screenshot of what http://ozoneasylum.com/ looks like in Firefox.

DmS
Maniac (V) Inmate

From: Sthlm, Sweden
Insane since: Oct 2000

posted posted 07-25-2005 07:35

I agree with reiso here, there is nothing to stop you from scheduling a script to run through a list of sites, let php use some native commands "under the hood" to open, screencap and save the site.

You need to have permission to allow php to run code on the server using exec or similar though, not all providers do due to the risks.
/Dan

{cell 260} {Blog}
-{ ?There are two major products that come out of Berkeley: LSD and UNIX. We don't believe this to be a coincidence. - Jeremy S. Anderson" }-

AT
Bipolar (III) Inmate

From: Gainesboro, TN, USA
Insane since: Aug 2000

posted posted 07-25-2005 22:20

Thanks all, it's appreciated. I knew about opening up a browser on the server, but not enough of them out there have the prerequisites to do it.

And reisio, the way you answered me above made it 'sound' like you were being a smart arse.

I'm sorry for jumping to conclusions, forgive me?

Thanks again

Casey / AT
Personal
Song Lyrics
Family Recipes

reisio
Paranoid (IV) Inmate

From: Florida
Insane since: Mar 2005

posted posted 07-25-2005 22:44

Don't worry about it.

So you don't think your server will have the browsers?

AT
Bipolar (III) Inmate

From: Gainesboro, TN, USA
Insane since: Aug 2000

posted posted 07-26-2005 05:08

Hey reisio, thanks.

I can't say they wont, I have to do more research first.

This is something that'll be included within a software package and will need to run on all types of servers.

I've yet to be able to have the time to test it across all the host I have access to right now.

Hopefully soon though, thanks for your help as it's appreciated.

Casey / AT
Personal
Song Lyrics
Family Recipes

amikael
Bipolar (III) Inmate

From: övik
Insane since: Dec 2002

posted posted 07-26-2005 17:22

You can do it sorta, if you test this approach.
(Sorry, need to link to my 'monster' here)
http://www.naltabyte.se/xin2.asp

Open 'Record' and then open an app, and do some stuff, and then play it from the 'record' menu.

(^-^)b

« BackwardsOnwards »

Show Forum Drop Down Menu