Gossamer Forum
Home : General : Perl Programming :

Downloading by perl/socket

Quote Reply
Downloading by perl/socket
Hi guy's...

I need a script (witout more lib's please)
to download a zip/jpg file from an website.

This is what i did' sofar,
But it's a little problem to 'filter' the htmltag's

when you execute this script it will start with output.
Date: Sun, 26 Jan 2003 05:53:34 GMT
Server: Apache/1.3.26 (Unix) Debian GNU/Linux PHP/4.1.2

etc...
after the content/type he starts the download of the zipfile. and thats what i need to save.

Laugh
---------
Code:

#!/usr/bin/perl

use Socket;

$rhost = "192.168.0.1";
$port = 80;

$iaddr = inet_aton($rhost);
$paddr = sockaddr_in($port, $iaddr);

socket(SOCK, AF_INET, SOCK_STREAM, $proto) || die "socket: $!";
connect(SOCK, $paddr) || die "connect: $!";

select(SOCK);
$| = 1;
select(STDOUT);
print SOCK "GET http://video/test.zip HTTP/1.0\015\012";
print SOCK "Pragma: no-cache\015\012";
print SOCK "Cache-Control: no-cache\015\012";
print SOCK "User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)\015\012";
print SOCK "\015\012\015\012";

while(<SOCK>) { print;
##
##
##
}
exit 1;

Last edited by:

faon: Jan 25, 2003, 10:00 PM
Quote Reply
Re: [faon] Downloading by perl/socket In reply to
why not ......

Code:


use LWP::Simple;

getstore($remote_file, $local_file);
Quote Reply
Re: [adrockjames] Downloading by perl/socket In reply to
Make sure 200 is returned.

Code:
if (getstore( ... ) == 200) {
Quote Reply
Re: [adrockjames] Downloading by perl/socket In reply to
Hmmmz,

It could work, but i just dont wanna use Library's,

Unsure
But thanx for the tip's anyway :)

Kind Regards,

Rene,
Quote Reply
Re: [faon] Downloading by perl/socket In reply to
Why don't you want to use libraries?

You are already using them in any case...what do you think Socket.pm is ;)
Quote Reply
Re: [Paul] Downloading by perl/socket In reply to
In Reply To:
Why don't you want to use libraries?

You are already using them in any case...what do you think Socket.pm is ;)

heheh Wink I know, but sock is already installed on the most linux boxes.....

It's just that i dont like to get lost in those lib's they are need Smile

Kind Regards,

Rene