Skip to content

Command line program to bulk download images from webpage

License

Notifications You must be signed in to change notification settings

jasperalani/image-downloader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Image Downloader

A simple Python script to download all images from a given webpage.
Works on Linux, macOS, and Windows Subsystem for Linux (WSL).

😎 Features

  • Extract images from HTML <img> tags (including srcset) and CSS url() styles
  • Support for custom HTTP headers
  • Progress tracking with completion percentage
  • Skip existing images (optional re-download with flag)
  • Custom download folder location
  • Handles relative and absolute URLs
  • Choose a specific image from a srcset or fallback to first/last option

πŸš€ Quick Start

1. Clone the repository

git clone https://github.com/jasperalani/image-downloader.git
cd image-downloader

2. Install dependencies

First, make sure Python 3 is installed.

  • If using Windows WSL as your linux environment then you might have to create a local python environment:
python3 -m venv ~/python_custom_env
~/python_custom_env/bin/pip3 install requests beautifulsoup4 tqdm
  • If using other Linux/Mac:
pip install requests beautifulsoup4 tqdm

3. Run the script

  • Windows WSL:
~/python_custom_env/bin/python3 image-downloader.py https://example.com
  • Linux/Mac:
python3 image-downloader.py https://example.com

Replace https://example.com with the URL of the page you want to download images from.

πŸ’Ώ Command Line Arguments

Argument Description
website Website URL to scrape images from (required)
-f, --folder Folder location to download images (default: ./download)
-r, --redownload Redownload images that pre-exist in download folder
-d, --headers Custom headers in JSON format
-t, --timeout Request timeout in seconds (default: 10)
-c, --srcset Index of image to use from srcset (0-based index)
-cf, --srcset-use-first Fallback to first image in srcset if index is out of range (default: true). Set to false to fallback to the last image instead.

Examples

Download images to default folder:

image-downloader https://example.com

Download to a specific folder:

image-downloader https://example.com -f ./my_images

Force redownload of existing images:

image-downloader https://example.com -r

Use custom headers:

image-downloader https://example.com -d '{"User-Agent": "Custom Agent", "Referer": "https://example.com"}'

Set custom timeout:

image-downloader https://example.com -t 30

Use 4th image from srcset, and fallback to last image if out of range:

image-downloader https://example.com -c 4 -cf false

About

Command line program to bulk download images from webpage

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages