{"id":2843,"library":"wget","title":"wget","description":"The `wget` Python library (version 3.2) is a pure Python download utility designed for simple file retrieval from HTTP URLs. It provides basic functionality to download files, optionally displaying a progress bar. It is distinct from the widely-used command-line utility GNU Wget, which offers more advanced features. The package's last update was in 2015, making it largely unmaintained compared to newer alternatives.","status":"deprecated","version":"3.2","language":"en","source_language":"en","source_url":"http://bitbucket.org/techtonik/python-wget/","tags":["download","http","utility","file transfer","web scraping"],"install":[{"cmd":"pip install wget","lang":"bash","label":"Install with pip"}],"dependencies":[],"imports":[{"note":"While `download` is the primary function, importing `wget` directly and calling `wget.download()` is the common pattern, and `download` itself is not directly exposed as a top-level symbol for direct import.","wrong":"from wget import download","symbol":"wget","correct":"import wget"}],"quickstart":{"code":"import wget\nimport os\n\nurl = 'https://www.python.org/static/img/python-logo.png'\noutput_filename = 'python-logo.png'\n\n# Ensure clean state for demonstration\nif os.path.exists(output_filename):\n    os.remove(output_filename)\n\nprint(f\"Downloading {url}...\")\nfilename = wget.download(url, out=output_filename)\nprint(f\"\\nDownloaded to: {filename}\")\n","lang":"python","description":"This quickstart demonstrates how to download a file using the `wget.download()` function. The function returns the local filename of the downloaded content. The `out` parameter specifies the output filename, otherwise it defaults to the basename of the URL."},"warnings":[{"fix":"For new projects or if encountering issues, evaluate alternatives like `pip install py3-wget` or using `subprocess.run(['wget', 'url'])`.","message":"The `wget` library (version 3.2) has not been updated since October 2015 and is largely unmaintained. Consider using `py3-wget` for a more actively developed pure-Python solution or invoking the system's `wget` utility via Python's `subprocess` module for robust, feature-rich downloads.","severity":"breaking","affected_versions":"<=3.2"},{"fix":"To use the CLI `wget` from Python, ensure the `wget` command-line utility is installed on your system, then use `import subprocess; subprocess.run(['wget', 'your_url'])`.","message":"Installing the Python `wget` package via `pip install wget` does NOT install the command-line utility `wget` or provide a wrapper to it. It's a separate, pure-Python implementation. If you intend to use the powerful GNU Wget command-line tool, you must install it separately on your operating system (e.g., `apt install wget` on Linux, `brew install wget` on macOS) and then use Python's `subprocess` module to call it.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always check the return value of `wget.download()` to get the actual path of the downloaded file. To control output filename, use the `out` parameter: `filename = wget.download(url, out='my_file.txt')`.","message":"The `wget.download()` function returns the local filename of the downloaded file. It does not return the file content or a simple boolean indicating success. If the file already exists, it will rename the new download (e.g., `file.txt.1`).","severity":"gotcha","affected_versions":"All versions"},{"fix":"Use `line.strip()` or `line.rstrip('\\n')` to clean up strings before using them as URLs: `url = f\"http://example.com/{line.strip()}.zip\"`.","message":"When constructing URLs from user input or file reads (e.g., iterating lines from a text file), remember to strip any trailing newline characters (`\\n`). If not removed, the URL passed to `wget.download()` will be invalid, often leading to download failures like HTTP 404 errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For advanced scenarios, consider using `subprocess` with the system's `wget` command or a more feature-rich HTTP client library like `requests`.","message":"This pure Python `wget` library has fewer features than the GNU Wget command-line utility. It lacks advanced capabilities like recursive downloads, complex authentication, `robots.txt` adherence, and robust resume functionality for interrupted downloads (though `py3-wget` and the CLI `wget` support these).","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}