brian d foy > webreaper-0.31 > webreaper


Annotate this POD

View/Report Bugs


webreaper -- download a web page and its links


        webreaper [OPTIONS] URL



The webreaper program downloads web sites. It creates a directory, named after the host of the URL given on the command line, in the current working directory, and will optionally create a tarball of it.

Getting around web site misfeatures

This script has many features to make it look like a normal, interaction web browser. You can set values for some features, or use the defaults, enumerated later.

Set the user-agent string with the -a switch. Some web sites refuse to work with certain browsers because they want you to use Internet Explorer. While webreaper is not subject to javascript checks (except for ones that try to redirect you), some servers try that behind-the-scenes.

Set the referer [sic] string. Some sites limit what you can see based on how they think you got to the address (i.e. they want you to click on a certain link). The script automatically sets the referer strings for links it finds in web pages, but you can set the referer for the first link (the one you specify on the command line) with the -r switch.

Basic browser features

For websites that use a login and password, use the -u and -p switches. This feature is still a bit broken because it sends the authorization string for every address.

Script features

Watch the action by turning on verbose messages with the -v switch. If you run this script from another script, cron, or some other automated method, you probably want no output, so do not use -v. You can also set the WEBREAPER_VERBOSE environment variable.

To get even more output, use the -d switch to turn on debugging output. You can also set the WEBREAPER_DEBUG varaible.

You can create a single file of everything that you download by creating an archive with the -t switch, which creates a tarball.

The script limits its traversal to URLs below the starting URL. This may change in the future.

Command line switches


set the user agent string


list of file extensions to store (not yet implemented)


list of file extensions to skip (not yet implemented)


turn on debugging output


use this directory for downloads


store all files in the same directory (flat)

-h HOST1[,HOST2...]

allowed hosts, comma separated.


stop after requesting NUMBER resources, whether or not webreaper stored them


stop after storing NUMBER resources


referer for the first URL


password for basic auth


sleep between requests


create tar archive


username for basic auth


verbose ouput


create a zip archive


scrape a site, with a randomizing pause between requests

webreaper -s 10

make a tar archive

webreaper -t

make a zip archive

webreaper -z

make a tar and a zip archive

webreaper -t -z

set the user agent string

webreaper -a "Mozilla 19.2 (Sony PlayStation)"

stop after making 10 requests or storing 5 files, whichever comes first

webreaper -N 5 -n 10

Environment variables ^


Show debugging output (implies verbose output). This is the same as the -d switch.


Show progress information. This is the same as the -v switch.


Store downloads in this directory. Script uses the current working directory if this directory does not exist. This is the same as the -D switch.

Wish list

limit directory level
limit content types, file names to store
specify a set of patterns to ignore
do conditional GETs
Tk or curses interface?
create an error log, report, or something
download stats (clock time, storage space, etc)
multiple levels of verbosity for output
read items from a config file
allow user to add/delete allowed domains during runtime
ensure that path names are safe (i.e. no ..)


lwp-rget (comes with LWP)


This source is part of a SourceForge project which always has the latest sources in CVS, as well as all of the previous releases.

If, for some reason, I disappear from the world, one of the other members of the project can shepherd this module appropriately.


brian d foy, <>


Copyright 2003-4, brian d foy, All rights reserved.

You may use this program under the same terms as Perl itself.

syntax highlighting: