<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Bicosyes - since evermore... &#187; Perl</title>
	<atom:link href="http://bicosyes.com/category/programacion/perl/feed/" rel="self" type="application/rss+xml" />
	<link>http://bicosyes.com</link>
	<description></description>
	<lastBuildDate>Sat, 06 Mar 2010 20:03:06 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Instalar módulos de CPAN como paquetes .deb automáticamente</title>
		<link>http://bicosyes.com/instalar-modulos-de-cpan-como-paquetes-deb-automaticamente/</link>
		<comments>http://bicosyes.com/instalar-modulos-de-cpan-como-paquetes-deb-automaticamente/#comments</comments>
		<pubDate>Wed, 07 Jan 2009 16:10:37 +0000</pubDate>
		<dc:creator>blaxter</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[cpan]]></category>
		<category><![CDATA[deb]]></category>
		<category><![CDATA[modules]]></category>

		<guid isPermaLink="false">http://bicosyes.com/?p=695</guid>
		<description><![CDATA[En un sistema basado en paquetes .deb (Debian, ubuntu, etc...) es bastante común tener una gran cantidad de módulos perl ya empaquetados en los repositorios pertinentes. La traducción del nombre del módulo al nombre del paquete es inmediata, Nombre::Del::Paquete se convertiría a libnombre-del-paquete-perl. Si resulta que tienes la mala suerte de no tener el que [...]]]></description>
			<content:encoded><![CDATA[<p>En un sistema basado en paquetes <em>.deb</em> (Debian, ubuntu, etc...) es bastante común tener una gran cantidad de módulos <em>perl</em> ya empaquetados en los repositorios pertinentes. La traducción del nombre del módulo al nombre del paquete es inmediata, <em>Nombre::Del::Paquete</em> se convertiría a <em>libnombre-del-paquete-perl</em>. Si resulta que tienes la mala suerte de no tener el que buscas, no pasa nada, existe una maravillosa herramienta llamada <strong>dh-make-perl</strong> (<em># aptitude install dh-make-perl</em>) que nos solucionará todo.</p>
<p>Tienes múltiples opciones de configuración, pero explicaré dos formas de usarla, la rápida, cómoda e instantánea (¡como el colacao!) y otra donde vas más paso a paso (es decir, que en vez de un comando, ejecutas dos, <em>joooplis</em>).</p>
<p><strong><u>Forma 1</u></strong>: Directamente se descargará el código y generará un .deb listo para ser instalado. </p>
<p>Digamos que quieres instalarte el módulo <em>Hola::Que::Tal</em>, pues ejecutas:</p>
<pre class="bash">$ dh-make-<span style="color: #c20cb9; font-weight: bold;">perl</span> --build --cpan Hola::Que::Tal</pre>
<p>Con eso estaremos descargando el código del paquete (si en cpan existe claro) y generando un <em>.deb</em> de forma automática. Si existen dependencias se te indicará qué módulos se requieren, en cuyo caso sería recomendable que mirases si los tienes en tus repositorios antes de generar un <em>.deb</em> para ellos también. </p>
<p>Por poner un ejemplo real:</p>
<pre class="bash">&nbsp;
$ dh-make-<span style="color: #c20cb9; font-weight: bold;">perl</span> --build --cpan Gtk2::Sexy
<span style="color: #7a0874; font-weight: bold;">&#40;</span>...<span style="color: #7a0874; font-weight: bold;">&#41;</span>
$ <span style="color: #c20cb9; font-weight: bold;">ls</span>
Gtk2-Sexy<span style="color: #000000;">-0.05</span>                     libgtk2-sexy-perl_0<span style="color: #000000;">.05</span>.orig.<span style="color: #c20cb9; font-weight: bold;">tar</span>.gz
libgtk2-sexy-perl_0<span style="color: #000000;">.05</span>-1_i386.deb
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> dpkg -i libgtk2-sexy-perl_0<span style="color: #000000;">.05</span>-1_i386.deb</pre>
<p><strong><u>Forma 2</u></strong>: Tenemos un <em>.tar.gz</em> descomprimido descargado de cpan, generaremos la estructura de ficheros necesaria para generar un <em>.deb</em> con las herramientas típicas de debian (con <em>debuild</em>, <em>$ sudo aptitude install devscripts</em>).</p>
<p>Por seguir el ejemplo anterior, si quisiéramos instalar el módulo <em>Hola::Que::Tal</em> versión 1.0, nos descargamos de cpan su <em>tar.gz</em> y lo descomprimimos, por lo que tendríamos un directorio con el nombre <em>Hola-Que-Tal-1.0</em>. Con <em>dh-make-perl</em> generaremos los ficheros necesarios para poder generar un paquete deb (es decir, se creará un directorio <em>debian/ </em>con ficheros varios, los cuales, si sabes para qué sirven y quieres complicarte la vida, puedes modificarlos a mano para personalizar el <em>.deb</em> generado). Después simplemente entramos en el directorio y generamos el <em>.deb</em> ejecutando <em>debuild</em>.</p>
<pre class="bash">&nbsp;
$ <span style="color: #c20cb9; font-weight: bold;">ls</span>
Hola-Que-Tal<span style="color: #000000;">-1.0</span>.<span style="color: #c20cb9; font-weight: bold;">tar</span>.gz
$ <span style="color: #c20cb9; font-weight: bold;">tar</span> xfz Hola-Que-Tal<span style="color: #000000;">-1.0</span>.<span style="color: #c20cb9; font-weight: bold;">tar</span>.gz
$ dh-make-<span style="color: #c20cb9; font-weight: bold;">perl</span> Hola-Que-Tal<span style="color: #000000;">-1.0</span>/
<span style="color: #7a0874; font-weight: bold;">&#40;</span>...<span style="color: #7a0874; font-weight: bold;">&#41;</span>
$ <span style="color: #7a0874; font-weight: bold;">cd</span> Hola-Que-Tal<span style="color: #000000;">-1.0</span>
$ debuild
<span style="color: #7a0874; font-weight: bold;">&#40;</span>...<span style="color: #7a0874; font-weight: bold;">&#41;</span>
$ <span style="color: #c20cb9; font-weight: bold;">ls</span> .. | <span style="color: #c20cb9; font-weight: bold;">grep</span> .deb
libhola-que-tal-perl_1<span style="color: #000000;">.0</span>-1_i386.deb</pre>
<img src="http://bicosyes.com/?ak_action=api_record_view&id=695&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://bicosyes.com/instalar-modulos-de-cpan-como-paquetes-deb-automaticamente/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Limpiado Ad-Free Blogs (II), esta vez de verdad!</title>
		<link>http://bicosyes.com/limpiado-ad-free-blogs-ii-esta-vez-de-verdad/</link>
		<comments>http://bicosyes.com/limpiado-ad-free-blogs-ii-esta-vez-de-verdad/#comments</comments>
		<pubDate>Tue, 03 Oct 2006 20:33:55 +0000</pubDate>
		<dc:creator>blaxter</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://bicosyes.com/limpiado-ad-free-blogs-ii-esta-vez-de-verdad/</guid>
		<description><![CDATA[Hace un rato me he acordado de que aún tenía esto pendiente por hacer, el script fallaba con todas las páginas que usaban redirecciones (debido a que éstas usan frames para hacer la redirección), lo cual he arreglado modificando ligeramente el código. &#160;El funcionamiento del script es sencillo, creamos un fichero de texto que se [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/wp-content/adfreebutton.jpg" class="flota" />Hace un rato me he acordado de que aún tenía <a href="http://bicosyes.com/limpiando-ad-free-blogs/">esto pendiente por hacer</a>, el script fallaba con todas las páginas que usaban <strong>redirecciones</strong> (debido a que éstas usan frames para hacer la redirección), lo cual he arreglado modificando ligeramente el código. <br />&nbsp;<br />El funcionamiento del script es sencillo, creamos un fichero de texto que se llame "<em>content.txt</em>" que tenga <a href="http://wiki.microsiervos.com/Ad-Free_Blogs">la página del <strong>wiki de microsiervos</strong></a>, ejecutamos el script (está en <strong>perl</strong> y requiere un paquete, <i>$ sudo aptitude install libterm-progressbar-perl</i>) y este creará <strong>tres ficheros</strong> de texto como salida
<ul>
<li><strong>out.txt</strong>: con los blogs buenos.</li>
<li><strong>out.txt.malos</strong>: con los blogs malos.</li>
<li><strong>errores.txt</strong>: con blogs que no ha podido analizar, debido a errores diversos, desde URL inexistentes (404) a falta de permisos debido a la configuración del servidor (403), etc, etc...</li>
</ul>
<p>Una vez terminada la ejecución (unos 20min le ha costado), he comprobado los blogs malos que da como resultado (unos cuantos solo, si comprobase todos no tendría sentido el script xD) y creo que esta vez no hay fallos. Los que salen como errores son debido a su mayoría a páginas no encontradas (error 404) o timeouts del servidor (error 500), aunque había algún otro error misterioso (415 por ejemplo) que lo he pasado a blogs buenos y ya está. En resumen, <strong>resultados</strong>:</p>
<blockquote>
<p>En total de 399 blogs. Hay 153 MALOS, 212 BUENOS y 34 que han fallado!</p></blockquote>
<p>Es decir, <strong>38% son malos!</strong> WTF?. Acabo de editarlo en el wiki de microsiervos, pero si alguien se aburre mucho, mucho y encuentra fallos en la lista (o en el código del script), que no dude en cagarse en mis muertos y mencionarlo para corregirlo cuanto antes. Ahora tendremos 216 blogs en ad-free <img src='http://bicosyes.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . <br />&nbsp;<br /> No voy a pegar todo el código pues es similar al anterior, <a href="/wp-content/adfreetar.gz">he aquí un tar.gz</a> con el código y ficheros resultado.</p>
<img src="http://bicosyes.com/?ak_action=api_record_view&id=323&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://bicosyes.com/limpiado-ad-free-blogs-ii-esta-vez-de-verdad/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Limpiando &#8220;Ad-Free Blogs&#8221;</title>
		<link>http://bicosyes.com/limpiando-ad-free-blogs/</link>
		<comments>http://bicosyes.com/limpiando-ad-free-blogs/#comments</comments>
		<pubDate>Mon, 04 Sep 2006 03:33:27 +0000</pubDate>
		<dc:creator>blaxter</dc:creator>
				<category><![CDATA[Internet & cia]]></category>
		<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://bicosyes.com/limpiando-ad-free-blogs/</guid>
		<description><![CDATA[Ad-Free Blogs es una iniciativa para crear una lista de weblogs libres de publicidad comercial de empresas. Microsiervos en su wiki creó la iniciativa en español de este movimiento. Un blog que quiera unirse, solo debe poner la imagen del buho y añadirse al wiki él mismo, y de ese modo incluso se tiene un [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://bicosyes.com/wp-content/adfreebutton.jpg" style="display:inline; float: right; margin:10px;"/><strong>Ad-Free Blogs</strong> es una iniciativa para crear una lista de weblogs libres de publicidad comercial de empresas. <a href="http://wiki.microsiervos.com/Ad-Free_Blogs"><strong>Microsiervos</strong> en su wiki</a> creó la iniciativa en español de este movimiento. Un blog que quiera unirse, solo debe poner la imagen del buho y añadirse al wiki él mismo, y de ese modo incluso se tiene un enlace para navegar al azar por estos blogs (libres de publicidad). <br />&nbsp;<br />Hasta aquí no estoy contanto nada nuevo. Hoy, aunque <strong>debería</strong> de haber estado estudiando, me he quedado en casa (solo "sé" estudiar en la biblio <img src='http://bicosyes.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> ) y cuando por la tarde estaba con mi bocata y mi coke todo feliz vagueando y tal, le he dado al link de blog al azar (el del buho) y de diez veces que le he dado, solo uno de los diez blogs era en verdad libre de publicidad (y que contuviese la imagen del buho). Como esto me ha molestado bastante, me he puesto a hacer un script simple que pilla el contenido de la página del wiki de microsiervos (hay que descargarlo y ponerlo en un txt) y va buscando en qué blogs tienen la imagen del buho y en cuales no. El script es simple y se puede mejorar por todos lados, lo acabo de hacer <img src='http://bicosyes.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> , pero los resultado <strong>creo</strong> que son buenos, aunque quiero comprobar más a fondo las direcciones que salen como malas <strong>antes</strong> de editar el wiki de Microsiervos. Concretamente los resultados que obtengo son:</p>
<blockquote><p>En total de 393 blogs. Hay 143 MALOS y 213 BUENOS</p></blockquote>
<p>Eso hace un <strong>36,4% de blogs malos y 9,4% erroneos (URL incorrecta)!</strong> Una cifra bastante considerable. El script es este:</p>
<pre class="perl"><span style="color: #808080; font-style: italic;">#!/usr/bin/perl -w</span>
<span style="color: #808080; font-style: italic;">################################################################################</span>
<span style="color: #808080; font-style: italic;"># adFreeClean v0.1 (menos da una piedra | A stone give you less) lol           #</span>
<span style="color: #808080; font-style: italic;">#                                                                              #</span>
<span style="color: #808080; font-style: italic;"># Author: Blaxter (blaxter at gmail dot com)                                   #</span>
<span style="color: #808080; font-style: italic;"># Date: 03/sept/2006                                                           #</span>
<span style="color: #808080; font-style: italic;"># Requiere:                                                                    #</span>
<span style="color: #808080; font-style: italic;">#     apt-get install libterm-progressbar-perl                                 #</span>
<span style="color: #808080; font-style: italic;"># Description:                                                                 #</span>
<span style="color: #808080; font-style: italic;">#     Mayormente pilla el archivo que se le indique, esperando que sea con el  #</span>
<span style="color: #808080; font-style: italic;"># formato wiki de http://wiki.microsiervos.com/Ad-Free_Blogs, y para cada url  #</span>
<span style="color: #808080; font-style: italic;"># de blog que encuentra, lo descarga y mira si tiene enlace a la página del    #</span>
<span style="color: #808080; font-style: italic;"># wiki o a la página adfreeblog.org                                            #</span>
<span style="color: #808080; font-style: italic;">#                                                                              #</span>
<span style="color: #808080; font-style: italic;">################################################################################</span>
<span style="color: #808080; font-style: italic;">#                                                                              #</span>
<span style="color: #808080; font-style: italic;">#                                GNU GPL license                               #</span>
<span style="color: #808080; font-style: italic;">#                                                                              #</span>
<span style="color: #808080; font-style: italic;">################################################################################</span>
<a href="http://perldoc.perl.org/functions/require.html"><span style="color: #000066;">require</span></a> LWP::<span style="color: #006600;">UserAgent</span>;
<span style="color: #000000; font-weight: bold;">use</span> Term::<span style="color: #006600;">ProgressBar</span>;
$| = <span style="color: #cc66cc;">1</span>;
<span style="color: #808080; font-style: italic;">################################################################################</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$FICHERO</span> = <span style="color: #ff0000;">'content.txt'</span>; <span style="color: #808080; font-style: italic;"># You should modify this</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$FICHERO_OUT</span> = <span style="color: #ff0000;">'out.txt'</span>; <span style="color: #808080; font-style: italic;"># You should modify this</span>
<span style="color: #808080; font-style: italic;">################################################################################</span>
<span style="color: #808080; font-style: italic;">################################################################################</span>
<span style="color: #000000; font-weight: bold;">sub</span> getURL
<span style="color: #808080; font-style: italic;"># Descarga una página</span>
<span style="color: #808080; font-style: italic;"># @param $1 la URL a bajar</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$ua</span> = LWP::<span style="color: #006600;">UserAgent</span>-&gt;<span style="color: #006600;">new</span>;
	<span style="color: #0000ff;">$ua</span>-&gt;<span style="color: #006600;">timeout</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #0000ff;">$ua</span>-&gt;<span style="color: #006600;">env_proxy</span>;	
&nbsp;
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$response</span> = <span style="color: #0000ff;">$ua</span>-&gt;<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span><a href="http://perldoc.perl.org/functions/shift.html"><span style="color: #000066;">shift</span></a><span style="color: #66cc66;">&#41;</span>;
&nbsp;
	<a href="http://perldoc.perl.org/functions/return.html"><span style="color: #000066;">return</span></a> <span style="color: #0000ff;">$response</span>-&gt;<span style="color: #006600;">content</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$response</span>-&gt;<span style="color: #006600;">is_success</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #ff0000;">''</span>;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #808080; font-style: italic;">###########################################</span>
<span style="color: #000000; font-weight: bold;">sub</span> checkadfree
<span style="color: #808080; font-style: italic;"># comprueba si una página tiene referencia a adfree</span>
<span style="color: #808080; font-style: italic;"># @param $1 Código Html de la página</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$pagina</span> = <a href="http://perldoc.perl.org/functions/shift.html"><span style="color: #000066;">shift</span></a>;
	<span style="color: #0000ff;">@expresiones</span> = <span style="color: #66cc66;">&#40;</span>
		<span style="color: #ff0000;">&quot;adfreeblog<span style="color: #000099; font-weight: bold;">\.</span>org&quot;</span>,
		<span style="color: #ff0000;">&quot;wiki<span style="color: #000099; font-weight: bold;">\.</span>microsiervos<span style="color: #000099; font-weight: bold;">\.</span>com<span style="color: #000099; font-weight: bold;">\/</span>Ad<span style="color: #000099; font-weight: bold;">\-</span>Free_Blogs&quot;</span>
	<span style="color: #66cc66;">&#41;</span>;
&nbsp;
	<span style="color: #b1b100;">foreach</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">@expresiones</span><span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
		<a href="http://perldoc.perl.org/functions/return.html"><span style="color: #000066;">return</span></a> <span style="color: #cc66cc;">1</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$pagina</span> =~ /<span style="color: #0000ff;">$_</span>/<span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
	<a href="http://perldoc.perl.org/functions/return.html"><span style="color: #000066;">return</span></a> <span style="color: #cc66cc;">0</span>;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #808080; font-style: italic;">################################################################################</span>
<span style="color: #808080; font-style: italic;">################################################################################</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@data</span>; <span style="color: #808080; font-style: italic;"># donde se guardarán los blogs</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$total_n</span> = <span style="color: #cc66cc;">0</span>; <span style="color: #808080; font-style: italic;"># numero total de blogs</span>
<span style="color: #808080; font-style: italic;"># abrir fichero del wiki...</span>
<a href="http://perldoc.perl.org/functions/open.html"><span style="color: #000066;">open</span></a> IN, <span style="color: #ff0000;">&quot;&lt;$FICHERO&quot;</span> <span style="color: #b1b100;">or</span> <a href="http://perldoc.perl.org/functions/die.html"><span style="color: #000066;">die</span></a> <span style="color: #ff0000;">&quot;Andandara el fichero!&quot;</span>;
<span style="color: #808080; font-style: italic;"># leemos todas las url's de paginas apuntadas</span>
<span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span><span style="color: #009999;">&lt;IN&gt;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>/^\*<span style="color: #66cc66;">&#91;</span>^\<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>*\<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span>^\<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span>*\<span style="color: #66cc66;">&#93;</span>$/io<span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #808080; font-style: italic;"># guardamos url, web(no usada, pero para otras versiones...), y linea</span>
		<span style="color: #808080; font-style: italic;"># entera para sacarla en el fichero resultado si es blog bueno</span>
		<span style="color: #0000ff;">$data</span><span style="color: #66cc66;">&#91;</span><span style="color: #0000ff;">$total_n</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#123;</span><span style="color: #ff0000;">'linea'</span><span style="color: #66cc66;">&#125;</span> =
		<span style="color: #0000ff;">$data</span><span style="color: #66cc66;">&#91;</span><span style="color: #0000ff;">$total_n</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#123;</span><span style="color: #ff0000;">'url'</span><span style="color: #66cc66;">&#125;</span> =
		<span style="color: #0000ff;">$data</span><span style="color: #66cc66;">&#91;</span><span style="color: #0000ff;">$total_n</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#123;</span><span style="color: #ff0000;">'web'</span><span style="color: #66cc66;">&#125;</span> =
		<span style="color: #0000ff;">$_</span>;
		<span style="color: #0000ff;">$data</span><span style="color: #66cc66;">&#91;</span><span style="color: #0000ff;">$total_n</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#123;</span><span style="color: #ff0000;">'url'</span><span style="color: #66cc66;">&#125;</span> =~ <a href="http://perldoc.perl.org/functions/s.html"><span style="color: #000066;">s</span></a>/^\*<span style="color: #66cc66;">&#91;</span>^\<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>*\<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#91;</span>^\<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#93;</span>*<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#91;</span>^\<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span>*\<span style="color: #66cc66;">&#93;</span>$/$<span style="color: #cc66cc;">1</span>/io;
		<span style="color: #0000ff;">$data</span><span style="color: #66cc66;">&#91;</span><span style="color: #0000ff;">$total_n</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#123;</span><span style="color: #ff0000;">'web'</span><span style="color: #66cc66;">&#125;</span> =~ <a href="http://perldoc.perl.org/functions/s.html"><span style="color: #000066;">s</span></a>/^\*<span style="color: #66cc66;">&#91;</span>^\<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>*\<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span>^\<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#93;</span>*\<a href="http://perldoc.perl.org/functions/s.html"><span style="color: #000066;">s</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#91;</span>^\<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span>*<span style="color: #66cc66;">&#41;</span>\<span style="color: #66cc66;">&#93;</span>$/$<span style="color: #cc66cc;">1</span>/io;
		<span style="color: #0000ff;">$total_n</span>++;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
<a href="http://perldoc.perl.org/functions/close.html"><span style="color: #000066;">close</span></a> IN; <span style="color: #808080; font-style: italic;"># done</span>
<span style="color: #808080; font-style: italic;"># Creamos barra guays</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$next_update</span> = <span style="color: #cc66cc;">0</span>;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$n</span> = <span style="color: #cc66cc;">0</span>;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$progress</span> = Term::<span style="color: #006600;">ProgressBar</span>-&gt;<span style="color: #006600;">new</span><span style="color: #66cc66;">&#40;</span>
	<span style="color: #66cc66;">&#123;</span>
		name =&gt; <span style="color: #ff0000;">'AdFree'</span>,
		count =&gt; <span style="color: #0000ff;">$total_n</span>,
		ETA =&gt; <span style="color: #ff0000;">'linear'</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#41;</span>;
<span style="color: #0000ff;">$progress</span>-&gt;<span style="color: #006600;">minor</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #0000ff;">$progress</span>-&gt;<span style="color: #006600;">max_update_rate</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;"># y ahora a comprobar cuales tienen add-free</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">@data</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0000ff;">$next_update</span> = <span style="color: #0000ff;">$progress</span>-&gt;<span style="color: #006600;">update</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$n</span><span style="color: #66cc66;">&#41;</span><span style="color: #b1b100;">if</span> <span style="color: #0000ff;">$n</span> &gt;= <span style="color: #0000ff;">$next_update</span>; <span style="color: #808080; font-style: italic;"># actuliza barra!</span>
&nbsp;
	<span style="color: #0000ff;">$url</span> = <span style="color: #0000ff;">$_</span>-&gt;<span style="color: #66cc66;">&#123;</span><span style="color: #ff0000;">'url'</span><span style="color: #66cc66;">&#125;</span>; <span style="color: #808080; font-style: italic;"># pilla url!</span>
	<span style="color: #808080; font-style: italic;"># bajamos la pagina</span>
	<span style="color: #0000ff;">$pagina</span> = &amp;getURL<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$url</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$pagina</span> <span style="color: #b1b100;">ne</span> <span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0000ff;">$_</span>-&gt;<span style="color: #66cc66;">&#123;</span><span style="color: #ff0000;">'adfree'</span><span style="color: #66cc66;">&#125;</span> = checkadfree<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$pagina</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
	<span style="color: #b1b100;">else</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0000ff;">$_</span>-&gt;<span style="color: #66cc66;">&#123;</span><span style="color: #ff0000;">'adfree'</span><span style="color: #66cc66;">&#125;</span> = <span style="color: #cc66cc;">-1</span>;
	<span style="color: #66cc66;">&#125;</span>
	<span style="color: #0000ff;">$n</span>++; <span style="color: #808080; font-style: italic;"># para la barra!</span>
<span style="color: #66cc66;">&#125;</span>
<span style="color: #808080; font-style: italic;"># Completamos barra, pa por si aca...</span>
<span style="color: #0000ff;">$progress</span>-&gt;<span style="color: #006600;">update</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$total_n</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<a href="http://perldoc.perl.org/functions/open.html"><span style="color: #000066;">open</span></a> OUT, <span style="color: #ff0000;">&quot;&gt;$FICHERO_OUT&quot;</span>;
<a href="http://perldoc.perl.org/functions/open.html"><span style="color: #000066;">open</span></a> OUT_MALOS, <span style="color: #ff0000;">&quot;&gt;$FICHERO_OUT.malos&quot;</span>;
<span style="color: #0000ff;">$malos</span> = <span style="color: #0000ff;">$buenos</span> = <span style="color: #0000ff;">$notfound</span> = <span style="color: #cc66cc;">0</span>;
<span style="color: #b1b100;">foreach</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">@data</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$_</span>-&gt;<span style="color: #66cc66;">&#123;</span><span style="color: #ff0000;">'adfree'</span><span style="color: #66cc66;">&#125;</span> eq <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0000ff;">$malos</span>++;
		<a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> OUT_MALOS <span style="color: #0000ff;">$_</span>-&gt;<span style="color: #66cc66;">&#123;</span><span style="color: #ff0000;">'url'</span><span style="color: #66cc66;">&#125;</span>;
	<span style="color: #66cc66;">&#125;</span>
	<span style="color: #b1b100;">elsif</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$_</span>-&gt;<span style="color: #66cc66;">&#123;</span><span style="color: #ff0000;">'adfree'</span><span style="color: #66cc66;">&#125;</span> eq <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0000ff;">$buenos</span>++;
		<a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> OUT <span style="color: #0000ff;">$_</span>-&gt;<span style="color: #66cc66;">&#123;</span><span style="color: #ff0000;">'linea'</span><span style="color: #66cc66;">&#125;</span>;
	<span style="color: #66cc66;">&#125;</span>
	<span style="color: #b1b100;">elsif</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$_</span>-&gt;<span style="color: #66cc66;">&#123;</span><span style="color: #ff0000;">'adfree'</span><span style="color: #66cc66;">&#125;</span> eq <span style="color: #cc66cc;">-1</span><span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0000ff;">$notfound</span>++;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
<a href="http://perldoc.perl.org/functions/close.html"><span style="color: #000066;">close</span></a> OUT;
<a href="http://perldoc.perl.org/functions/close.html"><span style="color: #000066;">close</span></a> OUT_MALOS;
<a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #ff0000;">&quot;En total de $n blogs. Hay $malos MALOS y $buenos BUENOS<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;</pre>
<p><a href="http://bicosyes.com/code/adfree.tar.gz">Puedes descargarlo aquí</a>, incluye el script (adfreeclean.pl), la página del wiki de microsiervos (content.txt) y los resultados despues de la ejecución (out.txt y out.txt.malos).</p>
<p><b>Actualización [4 sept @ 23.20]</b>: El script falla para todas las webs que usan frames (es decir, todas con redirecciones...). Hay un modulo para perl que teoricamente lo resuelve, pero va dos veces, así que tendría que hacer la iteración y busqueda de los frames a pelo. Para otro día, que ahora no me apetece <img src='http://bicosyes.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<img src="http://bicosyes.com/?ak_action=api_record_view&id=292&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://bicosyes.com/limpiando-ad-free-blogs/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Peticiones HTTP con Perl</title>
		<link>http://bicosyes.com/peticiones-http-con-perl/</link>
		<comments>http://bicosyes.com/peticiones-http-con-perl/#comments</comments>
		<pubDate>Thu, 31 Aug 2006 01:50:31 +0000</pubDate>
		<dc:creator>blaxter</dc:creator>
				<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://www.bicosyes.com/peticiones-http-con-perl/</guid>
		<description><![CDATA[En la última Campus Party, como comenté en su post, estuve bastante tiempo con el concurso de seguridad web. Muchas veces para ir probando a mandar peticiones web concretas, GET o POST, había que usar "algo" que lo hiciese. Las opciones son varias, se podría usar un proxy, pero con él nos limitamos el poder [...]]]></description>
			<content:encoded><![CDATA[<p>En la última Campus Party,<a href="http://www.bicosyes.com/campus-party-2006/"> como comenté en su post</a>, estuve bastante tiempo con el concurso de seguridad web. Muchas veces para ir probando a mandar peticiones web concretas, GET o POST, había que usar "algo" que lo hiciese. Las opciones son varias, se podría usar <strong>un proxy</strong>, pero con él nos limitamos el poder tratar la respuesta del servidor o hacer cosas algo más complejas que una simple petición, esto mismo se puede aplicar a usar un telnet contra el servidor web remoto, así que al final, hay que usar un <strong>lenguaje de programación</strong> desde el cual abrimeros un <strong><a href="http://es.wikipedia.org/wiki/Socket">socket</a></strong> contra el puerto 80 del servidor web en cuestión, por el cual hablaremos <a href="http://www.ietf.org/rfc/rfc2616.txt"><strong>HTTP 1.1</strong></a>.<br />&nbsp;<br />Un amigo que también participó en el concurso, <strong><em>OddBug</em></strong>, como es un poco windosero (aunque ahora es medio GentooManPr0 xD) usó Visual Basic <img src='http://bicosyes.com/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> , en mi caso opté por usar Perl porque <strong>mola mogollón</strong> <img src='http://bicosyes.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . Así que vamos al asunto!, como narices crear una petición (y obtener la respuesta por parte del servidor) http. Vamos a crear un socket y ya está, más facil no puede ser <img src='http://bicosyes.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . Tenemos <b>dos</b> formas, la <em>tradicional</em>:</p>
<pre class="perl"><span style="color: #808080; font-style: italic;">#! /usr/bin/perl -w</span>
<span style="color: #000000; font-weight: bold;">use</span> Socket;
<span style="color: #000000; font-weight: bold;">use</span> strict;
<span style="color: #b1b100;">my</span><span style="color: #66cc66;">&#40;</span> <span style="color: #0000ff;">$host</span>, <span style="color: #0000ff;">$in_addr</span>, <span style="color: #0000ff;">$proto</span>, <span style="color: #0000ff;">$port</span>, <span style="color: #0000ff;">$addr</span>, <span style="color: #0000ff;">$file</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #0000ff;">$host</span> = <span style="color: #ff0000;">&quot;www.marca.es&quot;</span>;
<span style="color: #0000ff;">$file</span> = <span style="color: #ff0000;">&quot;/&quot;</span>; <span style="color: #808080; font-style: italic;"># el index vamos...</span>
<span style="color: #0000ff;">$port</span> = <span style="color: #cc66cc;">80</span>;
<span style="color: #0000ff;">$proto</span> = <a href="http://perldoc.perl.org/functions/getprotobyname.html"><span style="color: #000066;">getprotobyname</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'tcp'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #0000ff;">$in_addr</span> = inet_aton<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$host</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #0000ff;">$addr</span> = sockaddr_in<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$port</span>, <span style="color: #0000ff;">$in_addr</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #808080; font-style: italic;"># creamos el socket y conectamos al servidor</span>
<a href="http://perldoc.perl.org/functions/socket.html"><span style="color: #000066;">socket</span></a><span style="color: #66cc66;">&#40;</span>S, AF_INET, SOCK_STREAM, <span style="color: #0000ff;">$proto</span><span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">or</span> <a href="http://perldoc.perl.org/functions/die.html"><span style="color: #000066;">die</span></a> <span style="color: #ff0000;">&quot;socket: $!&quot;</span>;
<a href="http://perldoc.perl.org/functions/connect.html"><span style="color: #000066;">connect</span></a><span style="color: #66cc66;">&#40;</span>S, <span style="color: #0000ff;">$addr</span><span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">or</span> <a href="http://perldoc.perl.org/functions/die.html"><span style="color: #000066;">die</span></a> <span style="color: #ff0000;">&quot;connect: $!&quot;</span>;
<span style="color: #808080; font-style: italic;"># para flushear nada mas escribir en el socket</span>
<a href="http://perldoc.perl.org/functions/select.html"><span style="color: #000066;">select</span></a><span style="color: #66cc66;">&#40;</span>S<span style="color: #66cc66;">&#41;</span>; $| = <span style="color: #cc66cc;">1</span>; <a href="http://perldoc.perl.org/functions/select.html"><span style="color: #000066;">select</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">STDOUT</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;"># Una peticion normal GET</span>
<a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> S <span style="color: #ff0000;">&quot;GET $file HTTP/1.1<span style="color: #000099; font-weight: bold;">\n</span>HOST: $host<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
&nbsp;
<span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span><span style="color: #009999;">&lt;S&gt;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
	<a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
<p>Que es un poco fea, bastante similar a C, y no muy limpia. Y la forma <em>maja</em>, usar los <a href="http://cpan.org/modules/index.html">modulos de CPAN</a> que hacen grande a Perl. Lo anterior queda simplificado a esto:</p>
<pre class="perl"><span style="color: #808080; font-style: italic;">#! /usr/bin/perl -w</span>
<span style="color: #000000; font-weight: bold;">use</span> IO::<span style="color: #006600;">Socket</span>;
<span style="color: #000000; font-weight: bold;">use</span> strict;
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$host</span> = <span style="color: #ff0000;">&quot;www.marca.es&quot;</span>;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$file</span> = <span style="color: #ff0000;">&quot;/&quot;</span>; <span style="color: #808080; font-style: italic;"># el index vamos...</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$port</span> = <span style="color: #cc66cc;">80</span>;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$S</span> = IO::<span style="color: #006600;">Socket</span>::<span style="color: #006600;">INET</span>-&gt;<span style="color: #006600;">new</span>
<span style="color: #66cc66;">&#40;</span>
	Proto    =&gt; <span style="color: #ff0000;">&quot;tcp&quot;</span>,
	PeerAddr =&gt; <span style="color: #ff0000;">&quot;$host&quot;</span>,
	PeerPort =&gt; <span style="color: #ff0000;">&quot;$port&quot;</span>,
<span style="color: #66cc66;">&#41;</span>  <span style="color: #b1b100;">or</span> <a href="http://perldoc.perl.org/functions/die.html"><span style="color: #000066;">die</span></a> <span style="color: #ff0000;">&quot;cannot connect!&quot;</span>;
<span style="color: #808080; font-style: italic;"># para flushear nada mas escribir en el socket</span>
<a href="http://perldoc.perl.org/functions/select.html"><span style="color: #000066;">select</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$S</span><span style="color: #66cc66;">&#41;</span>; $| = <span style="color: #cc66cc;">1</span>; <a href="http://perldoc.perl.org/functions/select.html"><span style="color: #000066;">select</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">STDOUT</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #0000ff;">$S</span> <span style="color: #ff0000;">&quot;GET $file HTTP/1.1<span style="color: #000099; font-weight: bold;">\n</span>HOST: $host<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
<span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span>&lt;<span style="color: #0000ff;">$S</span>&gt;<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span> <a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #66cc66;">&#125;</span></pre>
<p>Más simple ya, imposible. Ahora ya solo queda variar las peticiones que se mandan. Un <strong>GET</strong> no tiene mucha complejidad, solo recordar que en HTTP 1.1 hay que indicar el host y al final hay dos saltos de linea:</p>
<pre class="perl"><span style="color: #0000ff;">$peticion</span> = <span style="color: #ff0000;">'GET /fichero/que/quiero/lala.php HTTP 1.1
HOST: www.LAwebQUEsea.com'</span>.<span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
&nbsp;
<a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #0000ff;">$S</span> <span style="color: #0000ff;">$peticion</span>
&nbsp;</pre>
<p>Para una peticion <strong>POST</strong>, tenemos que indicar la longitud de los datos que se envían, podemos usar algo del estilo (es un ejemplo inventado de un supuesto formulario para votar):</p>
<pre class="perl"><span style="color: #0000ff;">$voto</span> = <span style="color: #cc66cc;">10</span>;
<span style="color: #0000ff;">$discoID</span> = <span style="color: #cc66cc;">28912</span>;
&nbsp;
<span style="color: #0000ff;">$peticionPost</span>=<span style="color: #ff0000;">'POST /discos/votar.asp HTTP/1.1
Host: www.paginaQUEsea.com
Content-Type: application/x-www-form-urlencoded
Content-Length: '</span>;
&nbsp;
<span style="color: #0000ff;">$post</span> = <span style="color: #ff0000;">'accion=votar&amp;id='</span>.<span style="color: #0000ff;">$discoID</span>.<span style="color: #ff0000;">'&amp;voto='</span>.<span style="color: #0000ff;">$voto</span>
<span style="color: #0000ff;">$peticion</span> = <span style="color: #0000ff;">$peticionPost</span>.<a href="http://perldoc.perl.org/functions/length.html"><span style="color: #000066;">length</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$post</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>.<span style="color: #0000ff;">$post</span>
&nbsp;
<a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #0000ff;">$S</span> <span style="color: #0000ff;">$peticion</span>;
&nbsp;</pre>
<p>Además de esto podemos enviar muchas más cabeceras (Cookies con sesiones php u otras cosas, Referer's, User-Agents, etc, etc...). Luego ya, según el escenario, después de obtener el resultado del servidor, se podría tratar y buscar patrones o lo que nos interesase, las combinaciones y posibilidades son infinitas. </p>
<img src="http://bicosyes.com/?ak_action=api_record_view&id=285&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://bicosyes.com/peticiones-http-con-perl/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Script bitrateFind</title>
		<link>http://bicosyes.com/script-bitratefind/</link>
		<comments>http://bicosyes.com/script-bitratefind/#comments</comments>
		<pubDate>Sun, 19 Feb 2006 22:03:49 +0000</pubDate>
		<dc:creator>blaxter</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://www.bicosyes.com/script-bitratefind/</guid>
		<description><![CDATA[Hace un par de meses hice un script para convertir música mp3 a un bitrate elegido por el usuario, ahora, dos meses despues, me encuentro con el problema de que no paro de añadir música a la colección, y al final no se que discos tengo a 128 (el bitrate que quiero) y cuales no.
Mirar [...]]]></description>
			<content:encoded><![CDATA[<p>Hace un par de meses hice un <a href="http://www.bicosyes.com/script-recomprension-mp3-2/">script</a> para convertir música mp3 a un bitrate elegido por el usuario, ahora, dos meses despues, me encuentro con el problema de que no paro de añadir música a la colección, y al final no se que discos tengo a 128 (el bitrate que quiero) y cuales no.</p>
<p>Mirar cada disco uno a uno, no es una solución, pues me pegaría toda la tarde. Así que, como me aburro mucho estos días, esta mañana me he puesto ha hacer un script para que me diga <em>que directorios tienen mp3's con bitrate mayor a uno que le indico</em>. Además como me gustan mucho las estadisticas, he hecho que salgan también unas estadisticas globales de los bitrates.</p>
<p>El uso del script es:</p>
<blockquote><p><strong>bitrateFind</strong> [-r|--round] Directorio_base</p></blockquote>
<p>El parametro <em>round </em>significa si las estadisticas finales se darán redondeadas o no (se refiere a los bitrates, pues los mp3s con VBR al leerlos dan como valor de su bitrate la media, entonces si no se redondea, quedan muy feas las estadisticas xD).</p>
<p>Un ejemplo de ejecución sería este:</p>
<blockquote><p><em>[blaxter@helicon]:~/C/BlaxMusic/Trapt$</em> <strong>bitrateFind --round .</strong><br />
*Analizando los mp3's del directorio /media/C/BlaxMusic/Trapt<br />
Analisis: 100% [============================]D 0h00m00s</p>
<p>Dirs with mp3's with bitrate > 128<br />
./Trapt<br />
./Someone In Control</p>
<p>Con bitrate 128: 1 (4.3 %)      ===><br />
Con bitrate 192: 11 (47.8 %)    =============================><br />
Con bitrate 256: 11 (47.8 %)    =============================><br />
-Un total de 23 mp3s analizados</p></blockquote>
<p>Y otra ejecución podría ser esta <img src='http://bicosyes.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> :</p>
<blockquote><p><em>[blaxter@helicon]:~/C/BlaxMusic$</em> <strong>bitrateFind --round .</strong><br />
*Analizando los mp3's del directorio /media/C/BlaxMusic<br />
Analisis: 100% [============================]D 0h02m18s</p>
<p>Dirs with mp3's with bitrate > 128<br />
./Second - Invisible<br />
./Evanescence/Fallen (Brazil Edition)/cd2<br />
./Evanescence/Performance Live/Live on DC101 24-02-03<br />
<em>(...aqui van muchos directorios mas...)</em><br />
./Foo Fighters/Foo Fighters/(2003) One By One (Limited Edition)<br />
./Foo Fighters/Foo Fighters/(2003) One By One (Limited Edition)/Bonus CD</p>
<p>Con bitrate  < 112: 28 (0.6 %)  -><br />
Con bitrate 112: 28 (0.6 %)     -><br />
Con bitrate 128: 2810 (64.9 %)  =======================================><br />
Con bitrate 160: 89 (2.1 %)     =-><br />
Con bitrate 192: 1022 (23.6 %)  ==============-><br />
Con bitrate 256: 294 (6.8 %)    ====-><br />
Con bitrate > 256: 56 (1.3 %)   =><br />
-Un total de 4327 mp3s analizados</p></blockquote>
<p>Parece que voy a tener que usar el otro <a target="_blank" href="http://www.bicosyes.com/script-recomprension-mp3-2/">script</a> un poco xD. Pero al menos ahora ya se que tengo que convertir <img src='http://bicosyes.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .<br />
<br />
<a href="http://www.bicosyes.com/code/bitrateFind.txt">Aquí</a> para descargarlo</p>
<img src="http://bicosyes.com/?ak_action=api_record_view&id=72&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://bicosyes.com/script-bitratefind/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Script recomprension MP3</title>
		<link>http://bicosyes.com/script-recomprension-mp3-2/</link>
		<comments>http://bicosyes.com/script-recomprension-mp3-2/#comments</comments>
		<pubDate>Wed, 07 Dec 2005 21:09:25 +0000</pubDate>
		<dc:creator>blaxter</dc:creator>
				<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://www.bicosyes.com/?p=30</guid>
		<description><![CDATA[

Mi caso: se me ha jodido el ipod y voy a pasar de tener 15gb a 2gb, mmmm, tengo la música casi toda a 192..320 de bitrate, aja, ¡hay que bajar ese bitrate!.

Mi caso II: pillo una canción con bastantes bajos, agudos y muy variada vamos, ... , la oigo a 320, 192, 128....no consigo [...]]]></description>
			<content:encoded><![CDATA[<ul>
<li>
Mi caso: se me ha jodido el ipod y voy a pasar de tener 15gb a 2gb, mmmm, tengo la música casi toda a 192..320 de bitrate, aja, ¡hay que bajar ese bitrate!.</li>
<li>
Mi caso II: pillo una canción con bastantes bajos, agudos y muy variada vamos, ... , la oigo a 320, 192, 128....no consigo adivinar cual es cual, OK, soy sordo, gran ventaja! <img src='http://bicosyes.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> .</li>
<li>
Conclusión: convertir toda mi musica a 128 con lo que un album de 100mb me pasará a 40mb, reduzco en un 60%, no esta mal.</li>
</li>
<p>Herramientas a usar: lame. Me leo el man, aja, veo que puedo convertir fácilmente, pero hay un gran problema, llamado <strong>Id3</strong>, los cuales los quiero mantener, son la base de cualquier biblioteca musical decente. OK, me haré un script para leerlos y pasárselo como parámetros al lame, el cual me convertirá las canciones (e insertará la información del id3 que le paso).</p>
<p>No problem, perl al poder, script pequeño pero útil. En definitiva es un simple script para recomprimir mp3 <strong>sin</strong> perder los id3 de éstos, <strong><a href="http://www.bicosyes.com/code/recompress.txt">aqui esta</a></strong>.</p>
<ul>
<li>BUG_1: Algunos nombres de ficheros con caracteres que podríamos denominar como <em>raros</em> falla, mayormente porque en el script se "escapan" dichos caracteres, y posiblemente alguno me habré dejado. Una solución para esto es simplemente renombrar los ficheros problemáticos.</li>
<li>
BUG_2: cuando el id3 del genero no está conforme al estandar Id3V1 (es decir una lista determinada de generos, <em>lame --genre-list</em> para verlos), peta también, mejor porque así he detectado incoherencias en los id3 y los he arreglado.</li>
</ul>
<p>Por lo demás va a la perfección <img src='http://bicosyes.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . 50gb de musica convertida en 20 <img src='http://bicosyes.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> . Y desde entonces toda la música que me estoy bajando la convierto con este script <img src='http://bicosyes.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>En ambos casos, estos "bugs" (o features?), por supuesto, no hacen que se borren los mp3's ni nada. Simplemente saldrá un lista de los comandos que han fallado (y posiblemente verás en dicho comando un parámetro del estilo <em>--tg "__un_género__"</em> el cual no es un género válido id3 o algún símbolo <em>raro</em> en el nombre del fichero, puedes copypastear dicho comando y sabrás exactamente el porqué falla).</p>
<p>Las <strong>instrucciones</strong> para usarlo son simples. Hay que tener en cuenta que el script trabajará con los mp3 <strong>únicamente</strong> del <strong>directorio actual</strong>. Esto lo he hecho así porque suelo tener los mp3 divididos por discos (como es lo normal creo yo) y gracias a <a href="http://www.bicosyes.com/script-bitratefind/">otro script</a> primero detecto qué discos tienen bitrate mayor que 128, y luego voy carpeta por carpeta usando este. Proceso que se podría automatizar, cierto; pero me gusta así.</p>
<blockquote><p>
$ wget http://www.bicosyes.com/code/recompress.txt<br />
$ chmod +x recompress.txt<br />
$ sudo mv recompress.txt /usr/bin/recompress # o a algún sitio en tu path<br />
$ sudo aptitude install lame libterm-progressbar-perl libmp3-info-perl<br />
$ cd <em>MUSICA/directorio_con_mp3</em><br />
$ recompress
</p></blockquote>
<img src="http://bicosyes.com/?ak_action=api_record_view&id=30&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://bicosyes.com/script-recomprension-mp3-2/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

