Created
April 29, 2015 11:07
-
-
Save sucotronic/388b48f676bba031b625 to your computer and use it in GitHub Desktop.
comprobar correos automaticamente
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$curl = curl_init('http://aplicacionesweb.correos.es/localizadorenvios/track.asp?numero=PQ46TX0400262980150010A&idiomaCorreos=es_ES'); | |
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); | |
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.552.224 Safari/534.10'); | |
$html = curl_exec($curl); | |
curl_close($curl); | |
$dom = new DOMDocument(); | |
@$dom->loadHTML($html); | |
$xpath = new DOMXPath($dom); | |
$table = $xpath->query('//table[1]'); | |
$md5 = md5($table->item(0)->textContent); | |
$test = dirname(__FILE__).'/md5.txt'; | |
if (file_exists($test)) | |
{ | |
$md5f = file_get_contents($test); | |
if ($md5 != $md5f) | |
{ | |
// Enviar correo | |
mail('[email protected]', 'cambio en estado','http://aplicacionesweb.correos.es/localizadorenvios/track.asp?numero=PQ46TX0400262980150010A&idiomaCorreos=es_ES'); | |
file_put_contents($test, $md5); | |
} | |
} | |
else | |
{ | |
file_put_contents($test, $md5); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment