John writes..

>I was wondering if anybody knows how
>to fetch a url and read it's contents.
>I can't seem to get the complete array
>form the CrackURL method, any thoughts.
>
>use strict;
>use Win32::Internet;
>
>my @file1 = undef;
>my $Machine = Win32::NodeName();
>
>my $inet = new Win32::Internet();
>my $file = $inet->FetchURL("http://$Machine:port";);

Looks like you've copied an example from the doc too closely, 'port' is
the network port which you want to connect to the HTTP server on. Eg:

  $inet->FetchURL("http://some.machine:8081/";);

That would use port 8081. The default port is port 80, which is the
standard HTTP port, assuming that standard then you don't need to supply
the port at all, just:

  $inet->FetchURL("http://some.machine/";);

>   @file1 = $inet->CrackURL("http://$Machine:port",ICU_DECODE);

This line of code doesn't seem to match your stated requirements, and
I'm not sure if you've read the doc properly and know what it's meant to
do, or perhaps I've misunderstood your requirements. The CrackURL method
just takes the string that you pass to it and splits it up into the URL
components, so if you pass it "http://some.machine:8081"; then the array
you get will be:

  @file = ( 'http', 'some.machine', '8081' );

I think that Win32::Internet will also fill in any anonymous username or
password settings that you have set up for your Internet Explorer
(wininet.dll) settings. The CrackURL method is completely unrelated to
the content at the actual URL.

So, to answer your specific requirement (how to fetch a url and read
it's contents), this works:

  use Win32::Internet;
  my $i = Win32::Internet->new;
  my $page = $i->FetchURL( 'http://www.microsoft.com/');
  print '-' x 80, "\n$page\n", '-' x 80;
  __END__

Not sure if that's what you wanted.

-- 
  Jason King
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to