K
KnxDT
Zeta
SEO
:O Creo que si me servirá amigo, muchas gracias por tu aporte, ahora lo pruebo xD No hagas caso al comentario que dejé en TD, después de anlizarlo veo que puede servirme. Saludos!
Espero la contribución del script del anonimizador entonces 🙂
De momento aquí está lo que hice:
Titulo de la URL de una página con PHP
Obviamente no voy a obligarlos a entrar, porque si no me pongo autobombero y se arma un lío.
El código que armé es este:
[...]
Saludos.
PD: Si no lo entienden, se los explico, aunque es bastante sencillo de entender, los números 7 son debido a la longitud de las cadenas titles.
function get_site_name($url)
{
$page = file_get_contents($url);
preg_match('#<title>(.*)</title>#s', $page, $title);
if(!empty($title[1]))
{
return $title[1];
}
else
{
return "No se obtuvo el título";
}
}
<?
global $link_head;
global $link_time;
?>
<html>
<head>
<title>Redirigiendo a <?=$link_head?></title>
<meta http-equiv="refresh" content="<?=$link_time?>; URL=<?=$link_head?>">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<center>
<h1>Cargando la URL...</h1>
<br />
<img src="http://crix.us/loading.gif" />
<p>Por Favor espere <?=$link_time?> segundos mientras es redirigido hacia <strong><a href="<?=$link_head?>"><?=$link_head?></a></strong> Gracias.</p>
<?php
$url = "<?=$link_head?>";
$html = file_get_contents($url);
$ini = strpos ($html, '<title>');
$fin = strpos ($html, '</title>');
$long = $fin - $ini - 7;
$titulo = substr ($html, ($ini+7),$long);
echo $titulo;
// Si no se imprimen correctamente las tildes, quitar el siguiente comentario
// echo utf8_encode($titulo);
?>
<br />
</center>
<div class="clearer"></div>
</div>
</body>
</html>
[...]
Pongo algo así, pero no me funciona 🙁 Disculpen mi ignorancia. No sé como hacerlo funcionar, sólo quiero que meustre el titulo de la página para la relevancia en los anuncios. Es solo un fragmento del código, no es todo el código jejeje
Espero que lo haya hecho mal, por que espero que funcione de alguna manera xD Gracias!
<?
global $link_head;
global $link_time;
?>
<html>
<head>
<title>Redirigiendo a <?=$link_head?></title>
<meta http-equiv="refresh" content="<?=$link_time?>; URL=<?=$link_head?>">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<center>
<h1>Cargando la URL...</h1>
<br />
<img src="http://crix.us/loading.gif" />
<p>Por Favor espere <?=$link_time?> segundos mientras es redirigido hacia <strong><a href="<?=$link_head?>"><?=$link_head?></a></strong> Gracias.</p>
<?php
$url = $link_head;
$html = file_get_contents($url);
$ini = strpos ($html, '<title>');
$fin = strpos ($html, '</title>');
$long = $fin - $ini - 7;
$titulo = substr ($html, ($ini+7),$long);
echo $titulo;
// Si no se imprimen correctamente las tildes, quitar el siguiente comentario
// echo utf8_encode($titulo);
?>
<br />
</center>
<div class="clearer"></div>
</div>
</body>
</html>
<?=$xxx?>
Son variables desde el archivo index.php, este archivo es page_redirect.php, el cual es el template de la redirección.
Con el codigo que mostré no funciona Santiago 🙁
<?
global $link_head;
global $link_time;
?>
<html>
<head>
<title>Redirigiendo a <?=$link_head?></title>
<meta http-equiv="refresh" content="<?=$link_time?>; URL=<?=$link_head?>">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<center>
<h1>Cargando la URL...</h1>
<br />
<img src="http://crix.us/loading.gif" />
<p>Por Favor espere <?=$link_time?> segundos mientras es redirigido hacia <strong><a href="<?=$link_head?>"><?=$link_head?></a></strong> Gracias.</p>
<?php
$url = $link_head;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $urlstring);
curl_setopt($ch, CURLOPT_REFERER, "http://www.tusitio.com");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);
$titulo = 'No se pudo obtener el título';
if($data)
{
$ini = strpos ($html, '<title>');
$fin = strpos ($html, '</title>');
$long = $fin - $ini - 7;
$titulo = substr ($html, ($ini+7),$long);
}
echo $titulo;
// Si no se imprimen correctamente las tildes, quitar el siguiente comentario
// echo utf8_encode($titulo);
?>
<br />
</center>
<div class="clearer"></div>
</div>
</body>
</html>
<?
function extraertituloenlaces($web){
$viewsource = file_get_contents($web)or die('FAK!! no existe o algo esta mal');
$iniciotitulo = strpos($viewsource, '<title>') ;
$finaltitulo = strpos($viewsource, '</title>') - $iniciotitulo;
$titulo = substr($viewsource, $iniciotitulo+7, $finaltitulo-7);
echo '<a href='.$web.'>'. $titulo.'</a>' ;
}
extraertituloenlaces('http://www.forobeta.com');
?>
Mmm, no bro, no funciona.
Fijate
Gracias por la ayuda 😉
<?
global $link_head;
global $link_time;
?>
<html>
<head>
<title>Redirigiendo a <?=$link_head?></title>
<meta http-equiv="refresh" content="<?=$link_time?>; URL=<?=$link_head?>">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<center>
<h1>Cargando la URL...</h1>
<br />
<img src="http://crix.us/loading.gif" />
<p>Por Favor espere <?=$link_time?> segundos mientras es redirigido hacia <strong><a href="<?=$link_head?>"><?=$link_head?></a></strong> Gracias.</p>
<?php
$url = $link_head;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $urlstring);
curl_setopt($ch, CURLOPT_REFERER, "http://www.tusitio.com");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);
if($data)
{
$ini = strpos ($html, '<title>');
$fin = strpos ($html, '</title>');
$long = $fin - $ini - 7;
$titulo = 'Titulo curl: ' . substr ($html, ($ini+7),$long);
}
else
{
$titulo = 'No se pudo obtener el título';
}
echo $titulo;
// Si no se imprimen correctamente las tildes, quitar el siguiente comentario
// echo utf8_encode($titulo);
?>
<br />
</center>
<div class="clearer"></div>
</div>
</body>
</html>
<?php phpinfo(); ?>
<?
global $link_head;
global $link_time;
?>
<html>
<head>
<title>Redirigiendo a <?=$link_head?></title>
<meta http-equiv="refresh" content="<?=$link_time?>; URL=<?=$link_head?>">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<center>
<h1>Cargando la URL...</h1>
<br />
<img src="http://crix.us/loading.gif" />
<p>Por Favor espere <?=$link_time?> segundos mientras es redirigido hacia <strong><a href="<?=$link_head?>"><?=$link_head?></a></strong> Gracias.</p>
<?php
$url = $link_head;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $urlstring);
curl_setopt($ch, CURLOPT_REFERER, "http://www.tusitio.com");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$html = curl_exec($ch);
curl_close($ch);
if($html)
{
$ini = strpos ($html, '<title>');
$fin = strpos ($html, '</title>');
$long = $fin - $ini - 7;
$titulo = 'Titulo curl: ' . substr ($html, ($ini+7),$long);
}
else
{
$titulo = 'No se pudo obtener el título';
}
echo $titulo;
// Si no se imprimen correctamente las tildes, quitar el siguiente comentario
// echo utf8_encode($titulo);
?>
<br />
</center>
<div class="clearer"></div>
</div>
</body>
</html>
Un amigo me dijo que es imposible con PHP, que sólo se puede con AJAX. Gracias por toda la ayuda amigos!Titulo curl: 405 Method Not Allowed
:O Funciona! Es cierto, sólo con algunos enlaces, pero está perfecto amigo, te lo agradezco mucho!!! Gracias por tu tiempo y por tu aporte amigo.
curl_setopt($ch,CURLOPT_FOLLOWLOCATION);
curl_setopt($ch, CURLOPT_REFERER, "http://www.tusitio.com");
curl_setopt($ch,CURLOPT_FOLLOWLOCATION);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
Utilizamos cookies y tecnologías similares para los siguientes fines:
¿Aceptas las cookies y estas tecnologías?
Utilizamos cookies y tecnologías similares para los siguientes fines:
¿Aceptas las cookies y estas tecnologías?