url updated – PHP

  php

Q(Question):

What is the best way to know if a website was updated using php?

I tried maybe using the last modified date
but it seems that some sites dont have that
info.

Thank you all for your comments

Yang

A(Answer):

Yang Li Ke wrote:

What is the best way to know if a website was updated using php?

I tried maybe using the last modified date
but it seems that some sites dont have that
info.

I think your safer bet would be to save a copy of the page locally and
compare it to the page on the server.

–= my mail box only accepts =–
–= Content-Type: text/plain =–
–= Size below 10001 bytes =–

A(Answer):

"Yang Li Ke" <ya******@sympatico.ca> wrote in message
news:R0*******************@news20.bellglobal.com.. .

What is the best way to know if a website was updated using php?

I tried maybe using the last modified date
but it seems that some sites dont have that
info.

Thank you all for your comments

Yang

Grab the page, and run an md5 on the contents. save that, and check against
it.

however, any dynamic content such as the time, weather info, or number of
visitors, etc… will break the
comparison.

$prevCheck = "4410ec34d9e6c1a68100ca0ce033fb17";

$page = file(http://www.google.com);

$pageSum = md5($page);

if ($pageSum != $prevCheck)
print "Page changed\n";


Mike Bradley
http://www.gzentools.com — free online php tools

A(Answer):

CountScubula wrote:

$page = file(http://www.google.com);

$pageSum = md5($page);

Sorry Mike 🙂
md5($array) does *not* do what you expect !!

cat xx.php
#v+
<?php
$x=array();
echo md5($x), "\n";
$x[] = 1;
echo md5($x), "\n";
$x[] = 2;
echo md5($x), "\n";
$x[] = 3;
echo md5($x), "\n";
$x[] = 4;
echo md5($x), "\n";
$x[] = 5;
echo md5($x), "\n";
print_r($x);
?>
#v-

the output is
4410ec34d9e6c1a68100ca0ce033fb17
4410ec34d9e6c1a68100ca0ce033fb17
4410ec34d9e6c1a68100ca0ce033fb17
4410ec34d9e6c1a68100ca0ce033fb17
4410ec34d9e6c1a68100ca0ce033fb17
4410ec34d9e6c1a68100ca0ce033fb17
Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
[4] => 5
)

–= my mail box only accepts =–
–= Content-Type: text/plain =–
–= Size below 10001 bytes =–

A(Answer):

CountScubula wrote:

$page = file(http://www.google.com);
$page = file_get_contents($url); // or
$page = implode(”, file($url));
$pageSum = md5($page);

Nice Idea!

–= my mail box only accepts =–
–= Content-Type: text/plain =–
–= Size below 10001 bytes =–

A(Answer):

"Pedro Graca" <he****@hotpop.com> wrote in message
news:bt************@ID-203069.news.uni-berlin.de…

CountScubula wrote:

$page = file(http://www.google.com);

$pageSum = md5($page);

Sorry Mike 🙂
md5($array) does *not* do what you expect !!

Ah yes, my fault,

should read:

$prevCheck = "b5efa612c5221817eeb56ab6166b2f48";

$page = implode("",file("http://www.google.com"));
$pageSum = md5($page);


Mike Bradley
http://www.gzentools.com — free online php tools

A(Answer):

"Yang Li Ke" <ya******@sympatico.ca> wrote in message
news:R0*******************@news20.bellglobal.com.. .

What is the best way to know if a website was updated using php?

I tried maybe using the last modified date
but it seems that some sites dont have that
info.

Thank you all for your comments

Yang

Ok, try this:
http://www.gzentools.com/snippetview…&v=pagelyt.php

Mike Bradley
http://www.gzentools.com — free online php tools

LEAVE A COMMENT