multiurl
multiurl is a Python package designed to simplify downloading multiple URLs, including support for multi-part URLs. It allows downloading several files into one or specific byte ranges from a single URL. Maintained by ECMWF, it has seen regular updates, with version 0.3.7 released in July 2025, indicating an active development cadence despite its listed 'Alpha' status on PyPI.
Warnings
- breaking The `cgi` module was removed from Python 3.13. `multiurl` versions prior to 0.3.2 may experience `ModuleNotFoundError` or other issues when running on Python 3.13+ if they relied on internal `cgi` usage.
- gotcha Versions prior to 0.3.7 might fail with `ChunkedEncodingError` during downloads, particularly when dealing with certain HTTP responses that use chunked transfer encoding.
- gotcha Older versions of `multiurl` (prior to 0.3.3) may incorrectly handle filenames derived from the `Content-Disposition` HTTP header, potentially leading to corrupted or misnamed downloaded files.
Install
-
pip install multiurl
Imports
- download
from multiurl import download
Quickstart
from multiurl import download
import os
# NOTE: For this quickstart, actual network requests are simulated for illustrative
# purposes to ensure it is runnable without external dependencies or network issues.
# In a real application, 'download' performs actual HTTP/FTP requests.
def simulated_download(url, target=None, parts=None, **kwargs):
print(f"\n--- Simulating download operation ---")
print(f" URLs(s): {url}")
print(f" Target file: {target}")
if parts:
print(f" Requested parts: {parts}")
print(f" Additional parameters: {kwargs}")
if target:
try:
with open(target, 'w') as f:
f.write(f"Simulated content for {target} from {url}\n")
print(f" Created simulated file: {target}")
except IOError as e:
print(f" Error creating simulated file {target}: {e}")
print("--- Simulation complete ---")
# Monkey-patch the actual download function for simulation in quickstart
# In a real application, you would just call `multiurl.download`
multiurl.download = simulated_download
# Example 1: Download a single URL into a specified target file
multiurl.download(url="http://example.com/data.txt", target="example_data.txt")
# Example 2: Download content from multiple URLs and combine into one file
multiurl.download(
url=["http://example.com/part1.json", "http://example.com/part2.json"],
target="combined_parts.json"
)
# Example 3: Download specific byte ranges (parts) from a single URL
# This requires the server to support HTTP Range requests.
multiurl.download(
url="http://example.com/large_file.bin",
parts=[(0, 1024), (2048, 512)],
target="file_segments.bin"
)
# Clean up simulated files (optional, for actual cleanup uncomment below)
# os.remove("example_data.txt")
# os.remove("combined_parts.json")
# os.remove("file_segments.bin")
print("\nQuickstart demonstration complete. Check your directory for simulated files.")