Funcion baja imagenes

Iniciado por mr.blood, Mayo 06, 2011, 01:29:46 PM

Tema anterior - Siguiente tema

0 Miembros y 1 Visitante están viendo este tema.

Mayo 06, 2011, 01:29:46 PM Ultima modificación: Marzo 14, 2015, 09:57:10 AM por Expermicid
Bueno, creo que este es mi 2º post aqui, ojala haya muchos mas ;).

Bien, he venido para traerles una funcion para bajar y guardar una imagen.

Código: perl
sub down_image
{
my $host=$_[0];
my $dir=$_[1];
my $dest=$_[2];
use IO::Socket::INET;
my $sock=IO::Socket::INET->new(PeerAddr=>$host,PeerPort=>"80",Proto=>"tcp");
print $sock "GET $dir HTTP/1.0\r\nHOST:$host\r\n\r\n";
my $convert=0;
my @rec=<$sock>;
open(file,">$dest");
foreach $rec(@rec)
{
if($convert==1)
{
print file $rec;
}
if($rec eq "\r\n")
{
$convert=1;
}
}
close(file);
}


Ejemplo de uso:

Código: perl
#!/usr/bin/perl

down_image("www.hackxcrack.es", "/forum/Themes/citiez_20rc5/images/custom/header.jpg", "foto.jpg");
sub down_image
{
my $host=$_[0];
my $dir=$_[1];
my $dest=$_[2];
use IO::Socket::INET;
my $sock=IO::Socket::INET->new(PeerAddr=>$host,PeerPort=>"80",Proto=>"tcp");
print $sock "GET $dir HTTP/1.0\r\nHOST:$host\r\n\r\n";
my $convert=0;
my @rec=<$sock>;
open(file,">$dest");
foreach $rec(@rec)
{
if($convert==1)
{
print file $rec;
}
if($rec eq "\r\n")
{
$convert=1;
}
}
close(file);
}


Sa1uDoS