Hola
Aqui tengo un programa que uso para Dólares Americanos
Código: Seleccionar todo
<?php
/*
Obtiene el tipo de cambio del diario oficial del dia
*/
$fecha = date("d-m-Y");
echo "fecha=$fecha\n";
$fecha_url = str_replace("-","%2F",$fecha);
$url = "http://dof.gob.mx/indicadores_detalle.php?cod_tipo_indicador=158&dfecha=".$fecha_url."&hfecha=".$fecha_url;
$txt = file_get_contents($url);
$txt = preg_replace('/\s\s+/', ' ', $txt);
preg_match_all("|>$fecha</td>.*<td.*>(\d*.\d*)</td|U",$txt,$out, PREG_PATTERN_ORDER);
if (is_array($out)) {
if (is_array($out[1])) {
@$tipo= (float)$out[1][0];
if ($tipo > 0) {
echo "tipo=$tipo\n";
}
}
}
?>
Ejemplo
Espero les sirva