-----Original Message-----
From: "Strehlau, Jörn" [SMTP:[EMAIL PROTECTED]]
Sent: Friday, April 28, 2000 13:50
To: Perl-Win32-Users Mailing List
Subject: AW: Downloading and Saving HTML Pages
And how do I fetch HTML pages through a Proxy with authentification?
Especially I am interested in getting gifs via perl.
Thanks.
Joern
I'd been wondering about that myself, so after jimi malcolm's question and
yours I did some research and found you can do this using LWP::simple, which
you can get from
http://theoryx5.uwinnipeg.ca/CPAN/data/libwww-perl/LWP/Simple.html
<http://theoryx5.uwinnipeg.ca/CPAN/data/libwww-perl/LWP/Simple.html>
Have a look at the readme file before anything else.
It states :
PREREQUISITES
In order to install and use this package you will need Perl version
5.004 or better. Some modules within this package depend on other
packages that are distributed separately from Perl. We recommend that
you have the following packages installed before you install
libwww-perl:
URI
MIME-Base64
HTML-Parser
libnet
Digest::MD5
You can install those via PPM straight from the net or get them from :
(if you've got a firewall problem)
http://www.activestate.com/ppmpackages/5.005/zips/
<http://www.activestate.com/ppmpackages/5.005/zips/>
Then the examples from the LWP::simple page work.
Here is the code I've successfully tested :
This one uses the system environment variables (just like PPM).
This can be handy as the same code will work for different configs
without changes.
# Must set HTTP_proxy=http://proxy.myorg.com:8080
# Must set HTTP_proxy_user=proxy_user
# Must set HTTP_proxy_pass=proxy_password
# in environment for the following to work
use LWP::UserAgent;
$ua = LWP::UserAgent->new;
$ua->proxy(http => 'http://proxy.myorg.com:8080');
#$ua->proxy(ftp => 'http://proxy.myorg.com');
#$ua->proxy(wais => 'http://proxy.myorg.com');
#$ua->no_proxy(qw(no se fi));
my $req = HTTP::Request->new(GET => 'http://www.perl.com/');
print $ua->request($req)->as_string;
This one's got all config in the code, so needs no environment vars :
use LWP::UserAgent;
$ua = new LWP::UserAgent;
$ua->proxy(['http', 'ftp'] => 'http://proxy.myorg.com:8080');
$req = new HTTP::Request 'GET',"http://www.perl.com";;
$req->proxy_authorization_basic("proxy_user", "proxy_password");
$res = $ua->request($req);
print $res->content if $res->is_success;
Make sure you replace proxy.myorg.com, proxy_user and proxy_password
with your own config
Cheers.
_____________________________________________
Bruno Bellenger
Sr. Network/Systems Administrator
> -----Ursprüngliche Nachricht-----
> Von: Philip Newton [SMTP:[EMAIL PROTECTED]]
> Gesendet am: Freitag, 28. April 2000 12:59
> An: Perl-Win32-Users Mailing List
> Betreff: Re: Downloading and Saving HTML Pages
>
> jimi malcolm wrote:
> > if someone could point me in the right direction, that would
> > be enough.
>
> perldoc -q "fetch an HTML file"
>
> It's in perlfaq9.
>
> Cheers,
> Philip
>
> ---
> You are currently subscribed to perl-win32-users as:
> [EMAIL PROTECTED]
> To unsubscribe, forward this message to
> [EMAIL PROTECTED]
> For non-automated Mailing List support, send email to
> [EMAIL PROTECTED]
---
You are currently subscribed to perl-win32-users as:
[EMAIL PROTECTED]
To unsubscribe, forward this message to
[EMAIL PROTECTED]
For non-automated Mailing List support, send email to
[EMAIL PROTECTED]
---
You are currently subscribed to perl-win32-users as: [archive@jab.org]
To unsubscribe, forward this message to
[EMAIL PROTECTED]
For non-automated Mailing List support, send email to
[EMAIL PROTECTED]