Anthony,
   As far as I'm aware, HTTP servers do not by default allow
wildcarding. I've never seen such a feature, but I'm sure somebody has
written an Apache module somewhere which allows this feature on the
server side.

If you control the webserver you could try upgrading to Apache2 and
using mod_dav. The Webdav protocol allows you to get parsable directory
listings from which you can then download whatever files you choose.

There is a Perl client library for WebDAV called HTTP::DAV (which I
wrote). HTTP::DAV can be retrieved from CPAN.

It is built on top of LWP (and so inherits all of LWP's great features),
and allows you to do as you wish:

        $dav->get('http://mickey/htdocs-test/tony.*', "/tmp");

http://www.webdav.org/perldav/

Regards,
Patrick.

-----Original Message-----
From: Anthony Thomas [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, 20 August 2003 3:02 AM
To: '[EMAIL PROTECTED]'
Subject: Question about wildcarding when getting files with LWP



Executing the code

   use LWP::UserAgent;
   $ua = LWP::UserAgent->new;
   $req1 = HTTP::Request->new(GET =>
'http://mickey/htdocs-test/tony.txt');
   $resp1 = $ua->request($req1);
   print "response code      = ", $resp1->code, "\n";
   print "response message   = ", $resp1->message, "\n";
   print "response base      = ", $resp1->base, "\n";
   print $resp1->as_string;

I receive the output

   response code      = 200
   response message   = OK
   response base      = http://mickey/htdocs-test/tony.txt

   Hi, Tony

   This is a test for LWP.

   Bye

(excluding the headers), which looks fine.  However, when I change to
the code

   use LWP::UserAgent;
   $ua = LWP::UserAgent->new;
   $req1 = HTTP::Request->new(GET =>
'http://mickey/htdocs-test/tony.*');

   $resp1 = $ua->request($req1);
   print "response code      = ", $resp1->code, "\n";
   print "response message   = ", $resp1->message, "\n";
   print "response base      = ", $resp1->base, "\n";
   print $resp1->as_string;

I get the following error output (excluding the headers):

   response code      = 404
   response message   = Not Found
   response base      = http://mickey/htdocs-test/tony.*
   
   <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
   <HTML><HEAD>
   <TITLE>404 Not Found</TITLE>
   </HEAD><BODY>
   <H1>Not Found</H1>
   The requested URL /htdocs-test/tony.* was not found on this
server.<P>
   <HR>
   <ADDRESS>Apache/1.3.19 Server at localhost Port 80</ADDRESS>
   </BODY></HTML>

Is wildcarding not allowed or am I going about this the wrong way?

The ultimate goal here is to save all remote files matching a given
wildcard locally under the same names as they had remotely?  In other
words...suppose there is a website http://www.junkABC.com that has files
named junk1.20030819, junk2.20030819, and junk4.20030819 that I need to
pick up using the wildcard junk*.20030819.  Is there a nice, concise way
to transfer these files without having to first go out and get a
directory listing, figure out which file names in the listing match the
wildcard, and then transfer them one by one.

Thanks.


Reply via email to