Forum Moderators: coopster

Message Too Old, No Replies

compare 2 files

         

jackvull

1:06 am on Jan 19, 2010 (gmt 0)

10+ Year Member



I download a file via curl every 10mins.
If the file is different (HTML code) then I want to email it to myself to have a look.
I tried this but it doesn't seem to compare the files.
Any ideas?

$savedfile = "ITMS_PTWL.html";
$myFile = "ITMS_PTWL_new.html";
$crc1 = strtoupper(dechex(crc32(file_get_contents($savedfile))));
$crc2 = strtoupper(dechex(crc32(file_get_contents($myFile))));

if ($crc1!=$crc2) {
// files not the same so email it
//and overwrite the old file
copy($myFile, $savedfile);

//then email

}

jackvull

2:16 am on Jan 19, 2010 (gmt 0)

10+ Year Member



Itg seems that the new file created by curl is a different dile size each time. Sounds strange?

coopster

1:10 pm on Jan 22, 2010 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Not strange if it actually is a different file size :)
Are you accidentally pulling the headers in with your content too perhaps?

jackvull

1:27 pm on Jan 22, 2010 (gmt 0)

10+ Year Member



Well, the file hasn't changed I don't think on visual inspection. I thought it might be something like a date or time that was getting changed on the page but can't see anything like that.
I think curl only pulls through the HTML...at least that's what's in the file.