Page 1 of 1

is it possible to take screenshots of webpages?

Posted: Sat Nov 26, 2005 5:38 pm
by unsuaulvb
is it possible to take screenshots of webpages? using php only like have a site take a pic of sitea every time it loads and displays a image of sitea

Posted: Sat Nov 26, 2005 6:52 pm
by John Cartwright

Posted: Sat Nov 26, 2005 7:12 pm
by unsuaulvb
i saw that but thank you im looking for someway to diplay a dynamic html page in a image any ideas

Posted: Sat Nov 26, 2005 7:25 pm
by John Cartwright
From one of the threads I posted, timv posted this

Code: Select all

firefox http://example.com -display localhost:0 &
import -window root -display localhost:0 myfile01.pcx /home/user/website/screenshot.png
chmod o+r /home/user/website/screenshot.png
If you are using *nix environment that is

Posted: Sun Nov 27, 2005 5:26 am
by foobar
@unsuaulvb:

Why don't you just use the code that I posted in the other thread? It retrieves the data from an XBox Live Card just fine. All you'd need to do is put it into a picture.

I've found a neat resource that shows you how to do exactly what you want to do:

http://www.ricocheting.com/perl/imgfly.html

It even gives you the code for it. But remember, no copy & paste...

Now, of course, you shouldn't forget about the PHP Manual:

http://php.net/gd


Oh, here's some more:

http://www.neowin.net/forum/index.php?showtopic=348463

You guessed it, I found this all in a matter of minutes with Google. Google is your friend!

Posted: Sun Nov 27, 2005 6:33 am
by m3mn0n
Indeed! :)

Posted: Sun Nov 27, 2005 2:23 pm
by unsuaulvb
i did use your code but some just like 2 things wasnt giving me the right info but thanks man you have been a huge help
but uh see ive been coding php mabye for a week and i really am not very good at it my code is always messy and over done, i can debug errors but for some reason i dont se any errors in my code but i get tons when i just try to test it

here it is

Code: Select all

<?php
/* Define GamerTag */
if ( $_GET['gamertag'] == "" ) {
    $gamertag = "No Gamertag";
} else {
   $gamertag = $_GET['gamertag'];
}

/* Format Text */
$name = str_replace(" ", "%20", $gamertag);
$name = str_replace(".png", "", $name);
$name = str_replace(".jpg", "", $name);
$name = str_replace(".gif", "", $name);
$name = str_replace(".card", "", $name);

/* Open file - change path to suit your needs */
$fp = fopen("http://gamercard.xbox.com/$name.card", 'r');

/* Read the card file */
while ($tmp = fread($fp, 4096)) {
  $file .= $tmp;
}

/* Match nick */
preg_match('@<span class="XbcFLAL">([^<]+)</span>@', $file, $matches);
$name = $matches[1];

/* Match avatar */
preg_match('@<img class="XbcgcGamertile" height="64" width="64" src="([^"]+)" />@', $file, $matches);
$avatar1 = $matches[1];

/* Match rep */
preg_match('@<img src="([^"]+)" />@', $file, $matches);
$rep = $matches[1];

/* Match score */
preg_match('@<span class="XbcFRAR">([\d]+)</span>@', $file, $matches);
$score1 = $matches[1];

/* Match zone */
preg_match('@<span class="XbcFRAR">([^<]+)</span>@', $file, $matches);
$zone1 = $matches[1];

/* Match game titles & icons */
preg_match_all('@<img height\="32" width\="32" title\="([^"]+)" alt\="" src="(http\:\/\/tiles\.xbox\.com\/tiles\/[\w]{2}\/[\w]{2}\/[^=]+\=\.jpg)" />@', $file, $matches);
$titles = $matches[1];
$games1 = $matches[2]; 

/* Define Rep Image */
if($rep=="http://gamercard.xbox.com/xweb/lib/images/gc_repstars_external_12.gif") {
$stars = "http://gamercard.xbox.com/xweb/lib/images/gc_repstars_external_12.gif";
} elseif($rep=="http://gamercard.xbox.com/xweb/lib/images/gc_repstars_external_13.gif") {
$stars = "http://gamercard.xbox.com/xweb/lib/images/gc_repstars_external_13.gif";
} elseif($rep=="http://gamercard.xbox.com/xweb/lib/images/gc_repstars_external_14.gif") {
$stars = "http://gamercard.xbox.com/xweb/lib/images/gc_repstars_external_14.gif";
} elseif($rep=="http://gamercard.xbox.com/xweb/lib/images/gc_repstars_external_15.gif") {
$stars = "http://gamercard.xbox.com/xweb/lib/images/gc_repstars_external_15.gif";
} elseif($rep=="http://gamercard.xbox.com/xweb/lib/images/gc_repstars_external_16.gif") {
$stars = "http://gamercard.xbox.com/xweb/lib/images/gc_repstars_external_16.gif";
} elseif($rep=="http://gamercard.xbox.com/xweb/lib/images/gc_repstars_external_17.gif") {
$stars = "src= http://gamercard.xbox.com/xweb/lib/imag ... nal_17.gif";
} elseif($rep=="http://gamercard.xbox.com/xweb/lib/images/gc_repstars_external_18.gif") {
$stars = "= http://gamercard.xbox.com/xweb/lib/imag ... nal_18.gif";
} elseif($rep=="http://gamercard.xbox.com/xweb/lib/images/gc_repstars_external_19.gif") {
$stars = "http://gamercard.xbox.com/xweb/lib/images/gc_repstars_external_19.gif";
} elseif($rep=="http://gamercard.xbox.com/xweb/lib/images/gc_repstars_external_20.gif") {
$stars = "http://gamercard.xbox.com/xweb/lib/images/gc_repstars_external_20.gif";
} else {
$stars = "";

/* Define BackGround */
$im = imagecreatefromgif("bg.gif");

/* Font Info */
$text = imagecolorallocate($im, 246, 246, 246);
$black = imagecolorallocate($im, 0, 0, 0);
$font = "X360.ttf"

/* Define Avatar */
$avatar1 = str_replace(".png", "", $avatar1)
$avatar1 = str_replace(".jpg", "", $avatar1);
$avatar1 = str_replace(".gif", "", $avatar1);
$avatar = imagecreatefromgif("$avatar1.jpg");

/* Define Gamerscore */
$score = "$score1";

/* Define Rep */
$stars = str_replace(".png", "", $stars);
$stars = str_replace(".jpg", "", $stars);
$stars = str_replace(".gif", "", $stars);
$rep = imagecreatefromgif("$stars.gif");

/* Define Games */
$games = "<img src= $games1>";

/* Define Zone */
$zone = "$zone1";

/* Define Text */
$zonetxt = "Zone";
$reptxt = "Rep";
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/*Imagettftext (int im, int size, int angle, int x, int y, int col, string fontfile, string text)*/
Imagettftext($im, 1,0,3,3,$text,'$font',$zonetxt);
?>
I also would like to state that i do know how to use GD properly
Image

see ^^^^ lol