in reply to Re: Mirroring Script
in thread Mirroring Script

The dirtiest way to do this is:
#!/usr/bin/perl -w use strict; for (1..273) { `wget http://www.my-site.com/mydir/?Page=$_`; }
Ouch! You're not kidding. Using backquotes in a void context! Not only is it messy because it forks needlessly (thanks to the question mark), but you're also capturing the output just to discard it!

Here's code that will be much saner and faster. In fact, you can run it multiple times, and it downloads only the changed files, if "if-modified-since" is supported by the server:

use LWP::Simple qw(mirror); for (1..273) { mirror "http://www.my-site.com/mydir/?Page=$_", "file$_"; }

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
Re: Re: Re: Mirroring Script
by BazB (Priest) on Feb 05, 2002 at 16:51 UTC

    Note: this code is untested, and is missing any sort of error checking and assumes you're using a UNIX like system with the wget command installed. Not much of a solution.
    Do not trust this code, but you get the idea.

    I think this disclaimer shows how little faith I put in that snippet :-)

    Certainly LWP::Simple is the way to go. merlyn++