What is the simplest way to go about checking whether a certain URL's HTML source code has changed since a cetain date. Another wards as soon as it changes I need to a function or variable would to be set to false. Or do I have to go about it by: keeping a variable set equal to the HTML source code (as the base /starting point) then run an infinite loop that keeps checking if the current source equals the variable(base line). How I tried just to see if the starting source equal the source I get from the function and it doesnt seem to be working -- this is what I have: <?php $start_source='<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>New Website Coming Soon</title> </head> <body> <p align="center"> </p> <p align="center"><font face="Courier New" color="#B1B1B1">New Website Coming Soon ...</font></p> <p align="center"> <img border="0" src="Kelly_Osbourne_Project_Catwalk_Small.jpg" width="295" height="354"></p> </body> </html>'; //highlight_file("http://rivalnyc.com/"); $end_new= highlight_file("http://www.kellyosbourne.com/",TRUE); if ( strcmp( $start_source,$end_source) == 0 ){ echo "they are the same"; } ?> could use some help.
ok chnaged it to use this function-- but still same problem, I am not geting any output start source is just a copy and paste of pages source code. end source is using the function to get current source code of page since nothing has changed if condition should be true. Heres the code <?php $start_source='<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>New Website Coming Soon</title> </head> <body> <p align="center"> </p> <p align="center"><font face="Courier New" color="#B1B1B1">New Website Coming Soon ...</font></p> <p align="center"> <img border="0" src="Kelly_Osbourne_Project_Catwalk_Small.jpg" width="295" height="354"></p> </body> </html> '; //highlight_file("http://rivalnyc.com/"); $end_new= file_get_contents("http://www.kellyosbourne.com/"); if ( strcmp( $start_source,$end_source) == 0 ){ echo "they are the same"; } ?> thanks in advance for any help
they arent going to be the same... you need to put in line breaks... matching the page... by the way... linebreaks are \n
A simpler way would be to use get_headers() and check for the Last-modified header. http://www.php.net/get_headers
^^ This header is optional though, and usually not sent when opening pages with a .php extension. (Since PHP is supposed to be a dynamic language, where the actual FILE remains the same while the content can change). I'd store an md5 hash of the source, and compare just these instead of the whole source. Takes way less space too.
when I tried the get_headers function I got an error saying call to an undefined function. heres what I tried. $url = "http://www.kellyosbourne.com/"; print_r(get_headers($url));
ok did the work around(function posted) in the user comments in the documentation. It worked fine for that other URL i posted. But then tried on a similar landing .HTML page/ URL it gave me " Array ( [0] => HTTP/1.1 302 Moved Temporarily [1] => Content-Length: 0 [2] => Location: /?e7547fa0 ) "
any other ways to get the headers. When I view the page info it shows the headers, so I dont why this is happening
ok.... let me quote you and try and explain i think this could be a solution... i could be wrong... what i was trying to say is you need to add \n to wherever there would be a new line because php will get rid of the whitespace i believe... ... let me test my theory real qiuck and i will update you
I dont think solution will work any longer as- I wanted to know as soon as a certain picture on a particular page has changed. However now that picture is in flash.
anyone have any thiought how to get a HTML pages source then coumapre it to the HTML that would be shown if I click 'view source' and match them up??