Diferencia entre revisiones de «Wikiquote:Frase del día»

Contenido eliminado Contenido añadido
Línea 31:
A continuación hay un listado de utilidades para que quienes deseen que la frase del día llegue a tu computador diaramente sin que tener que consultar la página principal de Wikiquote.
 
===Script en PerlJavascript===
Este esejemplo esta desarrollado como una '''pagina web''' simple que '''tiene un script en Perljavascript''' que hicesencillo para sacar la frase del día de la página principal. Espero que a alguien le resulte útil ;).
<pre><nowiki>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
#!/usr/bin/perl -w
<html xmlns="http://www.w3.org/1999/xhtml">
## Version 0.5 by kender (kendersec AT gmail DOT com) under GPL license
 
use IO::Socket;
 
<body onload="dame_frase_wikiquote ();">
## Creamos el socket
$sock = IO::Socket::INET -> new ( PeerAddr => 'es.wikiquote.org',
PeerPort => 80,
<script type="text/javascript"><!--
Proto => 'tcp'
var pon_frase_en_span = function (data) {
);
 
frase=data['parse']['text']['*'];
die "Fallo la conexion: $!\n" unless ($sock);
$sock->autoflush(1);
 
## Mandamos la peticion HTTP, tiene que ser asi para que pase por los proxys y otras seguridades
$url="GET /wiki/Portada HTTP/1.1\nConnection: close\nHost: es.wikiquote.org\nCache-Control: no-cache\nUser-Agent: Bot 0.1 Get the quote of
the day\n\n";
 
//con una alerta
print $sock "$url";
alert (frase);
 
///////////////////////////////////
@contenido=<$sock>;
//si para dentro de un span es asi:
$content="@contenido";
 
document.getElementById ('seoo').innerHTML =frase;
if($content eq NULL)
///////////////////////////////////
{
print "No conecta";
## Analizamos la web en busca del mensaje
$content =~ m/(<div style="text-align:center"><strong>«<i>(.*?)(<\/i>»|<\/i> <i>»<\/i>)<\/strong><\/div>)/;
$resultado = $2;
$resultado =~ s/<.*?>//g;
print "La frase celebre de hoy es:\n\n\t\"" . $resultado . "\"\n\n";
 
## Lo mismo con el autor y sus fechas
if ($content =~ m/(<div style="text-align:right;padding-right:2em"><small><a href="\/wiki\/.*?" title=".*?">(.*?)<\/a>
( <small>|<\/small>\s*?<p><small><small>)(.*?)<\/small><\/small>(<\/div>|<\/p>))/)
{
print "Aut\@r:\t" . $2 . "\t" . $3 . "\n"; ##Con fecha
else
{
$content =~ m/(<div style="text-align:right;padding-right:2em"><small><a href="\/wiki\/.*?"
title=".*?">(.*?)<\/a><\/small><\/div>)/;
print "Aut\@r:\t" . $2 . "\n"; ##Sin fecha
}
 
};
## Cerramos el socket
 
close $sock;
var dame_frase_wikiquote = function () {
var now = new Date ();
var day = now.getDay();
if(day == 0) titulo='{{Plantilla:Frase-domingo}}';
if(day == 1) titulo='{{Plantilla:Frase-lunes}}';
if(day == 2) titulo='{{Plantilla:Frase-martes}}';
if(day == 3) titulo='{{Plantilla:Frase-miércoles}}';
if(day == 4) titulo='{{Plantilla:Frase-jueves}}';
if(day == 5) titulo='{{Plantilla:Frase-viernes}}';
if(day == 6) titulo='{{Plantilla:Frase-sábado}}';
 
 
 
url = 'http://es.wikiquote.org/w/api.php?action=parse&text='+titulo+'&format=json&callback=pon_frase_en_span';
 
var elem = document.createElement ('script');
elem.setAttribute ('src', url);
elem.setAttribute ('type','text/javascript');
document.getElementsByTagName ('head') [0].appendChild (elem);
};
--></script>
 
 
<span id="seoo"></span>
 
</body>
 
</html>
</nowiki></pre>
[http://usuarios.lycos.es/kendersec/wikiquote/wikiquote.pl Descargar]
 
===Script en PHP===