dcool86

msg:4424735 | 4:53 pm on Mar 4, 2012 (gmt 0) |
What will be the quickest and most reliable way of doing that to. Thank you
|
brotherhood of LAN

msg:4424828 | 11:00 pm on Mar 4, 2012 (gmt 0) |
Do you need a method to fetch the page or a method to match the string? strpos [php.net] is good for the comparison PHP has support for cURL [php.net] and there are examples on that page.
|
dcool86

msg:4424874 | 4:06 am on Mar 5, 2012 (gmt 0) |
I was wondering if you could put together a code to look for <!-- BEGIN TEST CODE --> What I have written/tried doesn't work. Thank you
|
dcool86

msg:4425351 | 2:52 am on Mar 6, 2012 (gmt 0) |
This is what I have so far $ch = curl_init("http://www.example.com"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $text = curl_exec($ch); $test = strpos($text, "<!-- BEGIN TEST CODE -->"); if ($test==false) { echo "yes"; }else{ echo "no"; } I'm always getting a yes on any page even the one that has <!-- BEGIN TEST CODE --> what am I'm doing wrong?
|
dcool86

msg:4425366 | 3:23 am on Mar 6, 2012 (gmt 0) |
i got it to work but it doesn't seem to work on certain domains. Thanks
|
lostdreamer

msg:4428613 | 2:38 pm on Mar 13, 2012 (gmt 0) |
if(checkSite("http://www.google.nl")) echo "Found"; else echo "not Found";
function checkSite($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url ); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); $text = curl_exec($ch); $test = strpos($text, "<!-- BEGIN TEST CODE -->"); if ($test === false) return false; else return true; }
With strpos you should allways do a strict comparison ( === instead of == ) If the text would start with the text you are searching for, strpos will return 0 (since the search text starts at char 0) if 0 == false returns TRUE if 0 === false returns FALSE This just might be why you script fails On top of that, in your above script, the If Else logic is the wrong way around ;) Regards, LostDreamer
|
dcool86

msg:4429187 | 7:45 pm on Mar 14, 2012 (gmt 0) |
Thank you
|
|