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

For a static page, scrape image URLs by fetching its HTML, selecting relevant <img> elements, resolving each image path against the page URL, then downloading only files you are permitted to collect and use. Start by checking whether the site offers an API or export: it is usually preferable to scraping. The example below uses Python, Requests, and Beautiful Soup; it handles duplicate links, timeouts, HTTP errors, unsafe destinations, and file naming. It does not run JavaScript, so images inserted only after page load may require a different approach.

Before scraping, check for an API, access rules, and image rights

Look for a supported API or export before writing a scraper. The UC Santa Barbara Carpentries recommends checking for a web service or API and an existing wrapper first: Carpentries web-scraping guidance.

Then review the target site’s terms and access instructions and inspect its /robots.txt. RFC 9309 defines the Robots Exclusion Protocol as crawler guidance, not authorization; Google likewise explains that robots.txt is for crawler access management, not a security mechanism. An allow rule does not grant permission to reuse the images, and a disallow rule is not the only consideration. See the IETF RFC 9309 and Google’s robots.txt guide.

Keep request volume modest, particularly for large collections, and avoid collecting personal or confidential information. Publicly accessible does not mean free to republish. The U.S. Copyright Office notes that original website authorship may include photographs; fair use depends on the circumstances and has no universal number or percentage threshold. These are U.S. sources, not jurisdiction-specific legal advice. Check the image license, your intended use, and applicable law; seek permission or use suitably licensed images when needed. See the Copyright Office’s digital-files FAQ and fair-use FAQ.

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.

Scrape images from a static page with Python

Install the libraries

Use a recent Python 3 installation. Install Requests for HTTP requests and Beautiful Soup for parsing HTML:

python -m pip install requests beautifulsoup4

Run a cautious image downloader

Save the following as scrape_images.py. Replace PAGE_URL with a page you are authorized to access. The script extracts ordinary img[src] URLs, ignores non-HTTP(S) schemes, restricts downloads to the page’s host by default, avoids duplicate URLs, and gives files safe sequential names. The host restriction is deliberately conservative; only remove it if cross-host image delivery is expected and you have reviewed those destinations.

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.
from pathlib import Path
from urllib.parse import urljoin, urlsplit
import time

import requests
from bs4 import BeautifulSoup

PAGE_URL = "https://example.com/gallery/"
OUTPUT_DIR = Path("downloaded_images")
TIMEOUT_SECONDS = 20
PAUSE_SECONDS = 0.5

session = requests.Session()
session.headers.update({"User-Agent": "ImageCollector/1.0 (contact: you@example.com)"})

page = session.get(PAGE_URL, timeout=TIMEOUT_SECONDS)
page.raise_for_status()

soup = BeautifulSoup(page.text, "html.parser")
page_host = (urlsplit(PAGE_URL).hostname or "").lower()
image_urls = []
seen = set()

for img in soup.find_all("img"):
    src = img.get("src")
    if not src:
        continue

    image_url = urljoin(PAGE_URL, src.strip())
    parts = urlsplit(image_url)
    if parts.scheme not in {"http", "https"} or not parts.hostname:
        continue

    # Conservative safety check: only fetch from the page's host.
    if parts.hostname.lower() != page_host:
        continue

    if image_url not in seen:
        seen.add(image_url)
        image_urls.append(image_url)

OUTPUT_DIR.mkdir(parents=True, exist_ok=True)

for index, image_url in enumerate(image_urls, start=1):
    try:
        response = session.get(image_url, timeout=TIMEOUT_SECONDS, stream=True)
        response.raise_for_status()
        content_type = response.headers.get("Content-Type", "").split(";", 1)[0].lower()
        extensions = {
            "image/jpeg": ".jpg",
            "image/png": ".png",
            "image/gif": ".gif",
            "image/webp": ".webp",
            "image/svg+xml": ".svg",
            "image/avif": ".avif",
        }
        extension = extensions.get(content_type)
        if not extension:
            print(f"Skipped non-image response: {image_url} ({content_type or 'unknown type'})")
            continue

        output_path = OUTPUT_DIR / f"image_{index:04d}{extension}"
        with output_path.open("wb") as output:
            for chunk in response.iter_content(chunk_size=64 * 1024):
                if chunk:
                    output.write(chunk)
        print(f"Saved {output_path}")
        time.sleep(PAUSE_SECONDS)
    except requests.RequestException as error:
        print(f"Failed {image_url}: {error}")

Requests documents HTTP request behavior and exceptions in its official documentation; Beautiful Soup explains parsing and navigating HTML trees in its documentation. The code is a starting point, not a guarantee that every site’s images can or should be downloaded.

How the extraction works

  1. Fetch the page: session.get() retrieves the HTML. raise_for_status() stops processing on HTTP error responses.
  2. Parse tags: Beautiful Soup finds img elements in the returned HTML. It does not execute scripts.
  3. Resolve paths: urljoin() turns a relative path such as ../assets/photo.jpg into a URL. Python notes that an absolute second URL can replace the base host, which is why the example validates the hostname. See Python’s urljoin documentation.
  4. Download selectively: HTTP status, timeout, and content type are checked before saving. A pause spaces out requests; adjust it to keep traffic reasonable and follow the site’s instructions.

Choose useful images instead of downloading every image tag

A page’s img elements can include logos, icons, placeholders, decorative images, and unrelated thumbnails. Ryan Mitchell’s example in Web Scraping with Python highlights this filtering problem. Narrow the selection to the relevant page area or filter URLs using patterns specific to the site rather than assuming every image is part of the collection.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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.

The sample saves files with sequential names instead of trusting a URL’s filename, which may be missing, duplicated, or unsuitable for a local path. It also checks the response content type so an HTML error page is not saved as a picture. For a production collection, consider recording a manifest of source URLs and filenames, limiting total file size, and deciding how to handle retries and partial runs.

Handle responsive images and images missing from the HTML

Some pages use responsive-image markup such as srcset or defer loading until an image is near the viewport. The example intentionally reads only src; it may therefore miss a higher-resolution alternative or a deferred image. Inspect the actual markup and page behavior before adding site-specific extraction logic. Do not assume a placeholder src is the original image.

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

If the fetched document contains no image URL, the page may populate its content with client-side JavaScript. An HTML parser sees the retrieved document, not the browser-rendered result. A browser-rendered workflow may be needed, but its setup depends on the site and should be checked against current documentation for the browser automation tool selected. If the site provides an API, prefer that interface.

Make collection safer and more reliable

  • Validate destinations: URLs come from page content. Restrict them to expected hosts, as the code does. If you intentionally allow other hosts, validate them against an explicit list rather than accepting arbitrary URLs.
  • Keep the workload bounded: use a small delay, avoid repeatedly fetching the same resources, and stop if the site returns errors or indicates that your traffic is unwanted.
  • Handle failure explicitly: timeouts, rate limits, expired URLs, redirects, and server errors can interrupt downloads. The example reports request failures and continues; for important jobs, log errors and make retries limited and deliberate.
  • Protect local storage: the sequential file names avoid using untrusted URL paths as filenames. For large runs, check available disk space and set a maximum acceptable response size.
  • Keep provenance: record the source page and image URL alongside downloaded files when you need to audit where an asset came from.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common problems and fixes

Symptom Likely cause What to do
No images found The page HTML has no ordinary img[src] elements, or the images are added after JavaScript runs. Inspect the fetched HTML and the rendered page. Check for an API, responsive markup, or client-side rendering; this parser alone does not run JavaScript.
Relative URL fails The value was not converted relative to the correct page URL, or the resulting host is blocked by the conservative check. Use urljoin(PAGE_URL, src), inspect the resolved URL, and only allow a different host if it is expected and safe.
HTTP 403 or 429 The server refuses the request or is limiting traffic. Stop rather than trying to evade access controls. Check the site’s terms and API options; reduce request volume only where access is permitted.
Downloaded response is skipped The response did not advertise one of the recognized image content types. Inspect the response headers and site behavior. Do not rename an HTML error response as an image.
Timeout or intermittent failures The page or image host is slow, unavailable, or the connection is interrupted. Use a reasonable timeout, log failed URLs, and retry selectively with a limit rather than looping indefinitely.
Duplicate-looking files Different URLs may point to identical content, or query strings may produce different URLs for the same image. URL deduplication handles exact duplicates only. If deduplicating content is important, compare downloaded file hashes locally.

Or skip the browser setup

If you need a rendered screenshot rather than the original image files, ScreenshotNeo is a website screenshot API and MCP server. One GET request returns a PNG, JPEG, WebP, or PDF. It is not a replacement for extracting original image assets from a page; it captures the page as an image or document.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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.

Here is a one-call cURL example; replace the example URL and add your API key. See the ScreenshotNeo API documentation for options and response details.

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

ScreenshotNeo removes known cookie-consent banners, newsletter popups, and chat widgets before capture; those steps can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, with response headers identifying the page verdict and billing status. Its MCP server gives AI agents tools to take screenshots, inspect page information, and capture PDFs. The Free plan includes 1,000 shots per month without a card; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo’s free plan: 1,000 screenshots a month, no card required.

Frequently Asked Questions

Does robots.txt give me permission to download or republish images?

No. It is crawler guidance, not access authorization or a license to use image content. Check the site’s terms and the image’s rights separately.

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

Can I use this script to collect images from any website?

No. Site rules, technical access, image licenses, privacy, and applicable law vary. Check them before collecting or using files.

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.