<?


function GetHTML($d,$method,$vars,$ref='')
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,$d);
    curl_setopt($ch, CURLOPT_REFERER, $ref);
    curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch, CURLOPT_MAXREDIRS,3);
    curl_setopt($ch,CURLOPT_VERBOSE,0);   // me informará (si esta en cero) de todos los errores que halla curl
    curl_setopt($ch,CURLOPT_FOLLOWLOCATION,3);
    if ($method == 'POST')
    {
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $vars);
    }
    $buffer = curl_exec ($ch);
    curl_close ($ch);
    unset($ch);
    return $buffer;
}



$url = "https://infoclima.com/pronosticos/Argentina/Santa-Fe/Rosario/";
      $codigohtml = GetHTML($url);

preg_match_all("(<p>(.*)</p>)siU", $codigohtml, $temp);
preg_match_all("(Estado\", \"(.*)\")siU", $codigohtml, $estado);


$tempA =  $temp[1][0];
$estadoA =  $estado[1][0];
echo "a $tempA $estadoA";




$time = time();

include 'concha.php';

mysql_connect("$host","$usuario","$contra");
mysql_select_db ("$basedatos");
                    $sSQL=" UPDATE `configuracion` SET `como_esta` = '$estadoA', `grados` = '$tempA', `icon` = '$time' LIMIT 1";
                    mysql_db_query("$basedatos",$sSQL); };

/*

include '../url_amigable.php';

include '../concha.php';

mysql_connect("$host2","$usuario2","$contra2");
mysql_select_db ("$basedatos2");



$sql = "SELECT * FROM `q` WHERE analizado = 0 AND letra = ' ' LIMIT 10";



$consulta = mysql_query ($sql);

while ($row = mysql_fetch_array($consulta))

{

$ID  = $row["ID"];
echo "<h1>$ID</h1>";

$tema_ami =$row["tema_ami"];
$banda_ami =$row["artista_ami"];



$url = "https://www.letras.mus.br/$banda_ami/$tema_ami/";





      $codigohtml = GetHTML($url);


echo "$url <hr>";
preg_match_all("(p402_premium\">(.*)</div>)siU", $codigohtml, $href);

preg_match_all("(<div class=\"cnt-head_title\"> <h1>(.*)</h1>)siU", $codigohtml, $href1);



$letraA=  $href[1][0];
$letraA1=  $href1[1][0];

$letraA = utf8_decode($letraA);
echo $letraA;echo $letraA1;

$letraA1 = urls_amigables($letraA1);

if ($letraA1 == $tema_ami) { echo " si"; mysql_db_query("$basedatos2","
UPDATE `q` SET `letra` = '$letraA' WHERE `q`.`ID` = '$ID' LIMIT 1;

"); } else { echo " no";};

mysql_db_query("$basedatos2","
UPDATE `q` SET `analizado` = '1' WHERE `q`.`ID` = '$ID' LIMIT 1;

");





}

mysql_free_result($consulta);



/*


if ($hrefA == '') {} else {


echo "$ID $hrefA
";

$codigohtml11 = base64_encode($codigohtml);


/*
$hrefA = "https://www.cifraclub.com.br$hrefA";



if ($url)

$mystring = 'brhttp';
$pos = strpos($mystring, $url);

// Nótese el uso de ===. Puesto que == simple no funcionará como se espera
// porque la posición de 'a' está en el 1° (primer) caracter.
if ($pos === false) {

    mysql_db_query("acordesp_spider","

    INSERT INTO `urls` (`ID`, `url`, `analizado`, `html`, `cancion`) VALUES (NULL, '$hrefA', '0', '', '0');

    ");

} else {
}

};

};





mysql_db_query("acordesp_spider","

UPDATE `urls` SET `html` = '$codigohtml11' WHERE `urls`.`ID` = '$ID' LIMIT 1;

");


echo "--------------------------------


$url



";

?> *
