Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Python’s subprocess.run() to start the external GNU Wget program. Pass arguments as a list, leave shell=False (the default), set a timeout, and select Wget’s scope deliberately. For a page and its linked CSS, images, and other requisites, start with --page-requisites; do not add unrestricted recursion unless you intentionally want a crawl.

What “download a web page” can mean

Before writing code, choose the result you need:

  • Response data: fetch HTML so Python can parse or transform it. urllib.request or Requests is usually simpler.
  • Offline page copy: save HTML plus referenced stylesheets, images, and similar resources. Wget’s page-requisite mode is designed for this.
  • Site or section mirror: follow links recursively. This is a crawl, not a single-page download, and needs explicit limits.

GNU describes Wget as a non-interactive file downloader. It is a separate executable, so Python must be able to find it through PATH or through a verified absolute path.

Prerequisites and installation checks

Confirm Python and Wget

Install GNU Wget using your operating system’s trusted package source, then verify both programs from the same account that will run the script:

python --version
wget --version

Wget is available on most Unix-like systems and Windows, but package names, permissions, and executable locations vary. If wget is not found, install it or replace the command with a checked absolute path such as /usr/bin/wget or a Windows path. Do not assume that a Wget available in an interactive shell is also available to a service, scheduler, container, or virtual environment.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Check the options in your build

Option availability can differ between builds. Run wget --help and consult the manual installed with your version before deploying a command that depends on a particular flag.

Download one page and its requisites

This script saves a locally viewable copy of a page and the resources Wget identifies as required. --convert-links rewrites downloaded links for local viewing, while --adjust-extension gives HTML responses an appropriate filename extension.

import subprocess

url = "https://example.com/"
result = subprocess.run(
    [
        "wget",
        "--page-requisites",
        "--convert-links",
        "--adjust-extension",
        "--",
        url,
    ],
    check=True,
    timeout=120,
)
print("Downloaded successfully")

The -- separator marks the end of options. Keep it when the URL is supplied by another component; it prevents a value beginning with a hyphen from being interpreted as a Wget option. Python receives an argument sequence and does not invoke a shell by default. That avoids shell parsing and is safer than concatenating a command string.

Choose an output directory

Run the process with a controlled working directory so several downloads do not collide:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
from pathlib import Path
import subprocess

output_dir = Path("downloads/example")
output_dir.mkdir(parents=True, exist_ok=True)
subprocess.run(
    [
        "wget",
        "--page-requisites",
        "--convert-links",
        "--adjust-extension",
        "--directory-prefix", str(output_dir),
        "--",
        "https://example.com/",
    ],
    check=True,
    timeout=120,
)

Wget determines filenames and subdirectories from the URLs. If you need a single response body with a known name, use Wget’s output options only after checking how they interact with requisites; forcing every resource into one filename can overwrite files.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Handle failures and time limits in Python

check=True raises subprocess.CalledProcessError when Wget exits with a nonzero status. A timeout raises subprocess.TimeoutExpired. Catch both when a batch job should report an error and continue:

import subprocess

try:
    completed = subprocess.run(
        ["wget", "--page-requisites", "--convert-links", "--adjust-extension", "--", url],
        check=True,
        timeout=120,
        text=True,
        capture_output=True,
    )
except FileNotFoundError:
    print("Wget is not installed or is not on PATH")
except subprocess.TimeoutExpired:
    print("Wget exceeded the 120-second limit")
except subprocess.CalledProcessError as exc:
    print(f"Wget failed with exit code {exc.returncode}")
    print(exc.stderr)
else:
    print(completed.stdout)

Capture output when you need diagnostics; omit capture_output when an operator should see Wget’s progress directly. Set a timeout appropriate to the page and network rather than relying on an unbounded child process.

Do not use shell=True for untrusted URLs

With shell=True, your application becomes responsible for shell quoting and can expose command-injection risk when a URL or option is assembled from input. Prefer a list of arguments and the default shell=False. Validate allowed schemes and, where appropriate, restrict destinations to hosts your application is permitted to contact.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Page requisites versus recursive retrieval

Use page-requisite mode for one offline page

--page-requisites asks Wget to retrieve resources needed to display the selected page. Pairing it with --convert-links is a practical starting point for an offline copy. Modern sites may build content with JavaScript after the initial HTML response; Wget is not a full browser and may not execute that application code or see resources created only at runtime.

Use recursion only for a deliberate crawl

Recursive Wget follows links found in HTML, XHTML, and CSS. Limit depth with -l, and constrain the permitted area with suitable host or directory options. A conceptual, bounded invocation is:

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
subprocess.run(
    [
        "wget",
        "--recursive",
        "--level=1",
        "--page-requisites",
        "--convert-links",
        "--no-parent",
        "--",
        "https://example.com/docs/",
    ],
    check=True,
    timeout=600,
)

Review the manual for the exact scope controls you need. Unchecked recursion can consume disk space, bandwidth, memory, and CPU; the GNU manual warns that recursive retrieval should be used with care. Wget states that recursive retrieval respects /robots.txt, but that does not replace your legal, contractual, or operational review.

When Wget is the wrong tool

Fetch HTML for Python processing with urllib

from urllib.request import urlopen

with urlopen("https://example.com/", timeout=30) as response:
    html = response.read()

This uses Python’s standard library and returns response bytes directly. Reading the complete body is suitable only when its size is manageable. For large responses, copy or process the stream incrementally.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Requests for controlled HTTP workflows

Requests provides a higher-level HTTP API and documents streaming downloads. Its 2.34.2 documentation states official support for Python 3.10 and newer. It is a library, not a browser: neither urllib nor Requests automatically creates a browser-rendered offline copy with all dynamically generated assets.

Goal Best starting point Reason
Save one page with referenced assets Wget via subprocess.run Page-requisite and link-conversion features
Parse or transform a response urllib.request or Requests Data stays in Python; no external executable
Bounded link crawl Wget recursion with depth/scope limits Link following is explicit, but resource use must be controlled
JavaScript-rendered screenshot or PDF Browser-based capture service Wget does not render a complete interactive browser page

Common problems and fixes

“No such file or directory” or “wget is not recognized”

The executable is absent or not on the process PATH. Install Wget for the target machine, print the runtime environment’s PATH, or pass a verified absolute executable path.

Exit status is nonzero

Inspect the captured stderr and the URL’s HTTP response. Authentication, DNS, TLS, redirects, permissions, and unavailable resources can all produce failures. Decide whether your application should retry, skip the URL, or stop the batch; do not silently treat every nonzero status as success.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

The saved page looks unstyled

Confirm that page-requisite mode was used and that the output directory is writable. The page may load CSS or images through JavaScript, a blocked origin, authentication, or URLs Wget cannot resolve from the initial document. A browser-based capture is more appropriate when rendering depends on client-side execution.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The script hangs

Set a finite timeout, capture diagnostics, and consider Wget’s own network timeout/retry options after checking your installed version. For a crawl, reduce recursion depth and scope before increasing time limits.

Too many files or unexpected hosts

You probably enabled recursion or allowed cross-host links unintentionally. Remove recursion for a single page, set a depth, and restrict domains/directories. Test against a small staging URL before running a large job.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If your actual goal is a clean screenshot or PDF rather than an offline HTML tree, ScreenshotNeo provides a single website-screenshot API call. It accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be disabled. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the page verdict and billing status in headers.

cURL:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Python:

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

See the ScreenshotNeo documentation for authentication, output formats, and the 63 capture options. They include full-page lazy-image loading, CSS-selector element capture, device and viewport controls, dark mode, retina scale, PDF settings, custom CSS/JavaScript, clicks, waits, blocked resources, headers, cookies, user agents, authorization, timezone, geolocation, transparent backgrounds, resizing, selectable cache TTLs, signed image links, asynchronous webhooks, bulk capture of up to 100 URLs per call, usage data, and an OpenAPI specification. An MCP server supplies take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The Free plan includes 1,000 screenshots per month with no card. Paid plans start at $5 for 3,000 shots; yearly billing provides two months free, and every feature is available on every plan. Create a free ScreenshotNeo account to try it.

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Operational checklist

  • Define whether you need response bytes, one offline page, a bounded crawl, or a rendered capture.
  • Verify Wget is installed and accessible to the Python process.
  • Pass an argument list, retain shell=False, and include -- before the URL.
  • Set a timeout and handle FileNotFoundError, TimeoutExpired, and CalledProcessError.
  • Use page requisites without recursion for one page; set depth and scope for crawls.
  • Keep output directories isolated and monitor disk, bandwidth, and CPU usage.
  • Switch to urllib or Requests when Python needs response data rather than Wget’s file retrieval.

FAQ

Does Wget execute JavaScript?

Wget retrieves documents and resources; it is not a full browser runtime. Content generated only after client-side JavaScript runs may be absent.

Can I download a page that requires login?

Only if you provide credentials or session data in a way permitted by the site and your security policy. Treat cookies and authorization headers as secrets and avoid writing them into logs or command lines visible to other users.

Should I read the downloaded file with Python?

Yes. After Wget completes, open the known output path with Python and process it using the parser or transformation library your application requires.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Frequently Asked Questions

Does Wget execute JavaScript?

Wget retrieves documents and resources; it is not a full browser runtime. Content generated only after client-side JavaScript runs may be absent.

Can I download a page that requires login?

Only if you provide credentials or session data in a way permitted by the site and your security policy. Treat cookies and authorization headers as secrets and avoid writing them into logs or command lines visible to other users.

Should I read the downloaded file with Python?

Yes. After Wget completes, open the known output path with Python and process it using the parser or transformation library your application requires.

The Bottom Line

Launch Wget with subprocess.run and a list of arguments; use page requisites for one offline page, recursion only with strict limits, and urllib or Requests when your code needs response data instead of a file tree.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.