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.

Beautiful Soup turns HTML you already have into searchable Python objects; it does not download web pages. A basic scraper therefore needs two stages: fetch the page with an HTTP client such as Requests, then parse the returned HTML with Beautiful Soup. The example below checks the HTTP response, uses a timeout, and extracts links while safely handling missing attributes.

Install the packages

Install Beautiful Soup 4 and Requests in the Python environment that will run your script:

python -m pip install beautifulsoup4 requests

The package is named beautifulsoup4, but you import it from bs4. This guide uses Python’s built-in html.parser, so it does not require a separate parser package. If you choose lxml or html5lib instead, install that parser in the same environment.

Fetch a page and extract its links

Save this as scrape_links.py and run it with python scrape_links.py. Replace the example URL with a page you are allowed to access.

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.
import requests
from bs4 import BeautifulSoup
from urllib.parse import urljoin

url = "https://example.com/"

try:
    response = requests.get(
        url,
        timeout=(5, 30),  # connect timeout, then read timeout, in seconds
        headers={"User-Agent": "ExampleScraper/1.0"},
    )
    response.raise_for_status()
except requests.exceptions.Timeout:
    raise SystemExit(f"The request to {url} timed out")
except requests.exceptions.RequestException as exc:
    raise SystemExit(f"Could not fetch {url}: {exc}")

soup = BeautifulSoup(response.text, "html.parser")

for link in soup.find_all("a", href=True):
    href = link.get("href")
    text = link.get_text(" ", strip=True)
    absolute_url = urljoin(response.url, href)
    print(f"{text or '[no link text]'}: {absolute_url}")

requests.get() retrieves the response; raise_for_status() raises an error for unsuccessful HTTP status codes instead of letting the script quietly parse an error page as if it were normal content. The tuple passed to timeout sets separate connection and response-read limits. Requests has no timeout by default, so set one for scripts that must not wait indefinitely. The HTML parser then builds a tree, and find_all("a", href=True) selects anchors with an href attribute. urljoin() turns relative links into absolute URLs using the final response URL.

Choose an extraction method

Use find() for one matching element

find() returns the first match, or None if no element matches. Check the result before reading its attributes:

title = soup.find("h1")
if title is None:
    print("No h1 found")
else:
    print(title.get_text(" ", strip=True))

Use find_all() for multiple elements

find_all() returns all matching elements; it can return an empty list when there are no matches. It supports tag names and attribute filters:

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.
all_images = soup.find_all("img")
images_with_alt = soup.find_all("img", alt=True)
by_id = soup.find_all(id="main-content")

Use tag.get("attribute") when the attribute may be absent. For instance, tag.get("href") returns None rather than raising an error if an anchor has no href.

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

Use CSS selectors when they describe the target more clearly

select() returns all matches for a CSS selector, and select_one() returns the first match or None. For example:

cards = soup.select("article.product-card")
first_card_title = soup.select_one("article.product-card h2")

Beautiful Soup uses SoupSieve for many modern CSS selectors, but selector support can depend on the installed versions. If a selector behaves unexpectedly, verify the markup and the versions in your environment.

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.

Inspect the HTML before relying on a selector

A selector only works if the fetched response contains matching markup. Inspect a small portion of the returned page while developing:

print(response.status_code)
print(response.url)
print(response.text[:2000])

Look for stable tags and attributes rather than relying on text or deeply nested structure that may change. Test the extraction against several expected and missing cases; a scraper should handle absent elements deliberately rather than assuming every page has the same layout.

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

Select a parser deliberately

Beautiful Soup can build its tree with html.parser, lxml, or html5lib. The built-in parser needs no extra installation. The Beautiful Soup documentation describes lxml as faster and html5lib as parsing like a browser; malformed markup can produce different trees with different parsers. For repeatable results, specify the parser by name and make sure its dependency is installed. If raw parsing speed is the main concern, the documentation recommends using lxml directly rather than Beautiful Soup’s navigation layer.

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

Understand what a scraper can see

Requests receives the server response; Beautiful Soup parses that response. If a site fills the content only after JavaScript runs in a browser, that content may not appear in the HTML returned to Requests. Check the response body first. If the data is absent, a different permitted approach may be needed; changing a selector cannot extract content that was never returned.

Common problems and fixes

  • find_all() returns an empty list: print the status code and a portion of response.text, then confirm the current markup actually matches the tag, attribute, or CSS selector. The target content may not be in the server response.
  • find() causes a NoneType error: no match was found. Check for None before accessing attributes or text.
  • The script hangs or waits too long: pass a timeout to the request. Requests does not set one automatically.
  • The script parses an error page: call raise_for_status() before parsing and handle the resulting Requests exception.
  • Results differ across machines: specify the parser and ensure the chosen parser is installed. Different parsers may build different trees from malformed HTML.
  • ModuleNotFoundError: No module named 'bs4': install beautifulsoup4 using the Python interpreter for the environment running the script, for example python -m pip install beautifulsoup4.

Scrape responsibly and keep the script maintainable

  • Check the target site’s current terms and access guidance before collecting data; permission and rules can vary by site.
  • Keep request volume modest, and stop if the site blocks access.
  • Collect only the data you need, especially where pages contain personal information.
  • Handle timeouts, HTTP errors, and missing fields explicitly so a failed request does not silently become bad data.
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 you need screenshots rather than structured HTML fields, ScreenshotNeo is a website screenshot API and MCP server. One GET request can return a PNG, JPEG, WebP, or PDF. Its capture flow accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, with response headers identifying the page verdict and billing status. Its MCP server offers take_screenshot, get_page_info, and capture_pdf to AI agents and other MCP clients.

For example, install Requests if needed, then make a single call:

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

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

See the ScreenshotNeo API documentation for request options. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up for 1,000 free screenshots a month, with no card required.

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.

Frequently Asked Questions

Does Beautiful Soup download a web page?

No. Use an HTTP client such as Requests to fetch the page, then pass its response body to Beautiful Soup.

Why does Beautiful Soup return an empty list?

The response may not contain the expected content, or the selector may not match the current markup. Inspect the returned HTML and check whether the target element is present.

How do I find all links with Beautiful Soup?

Use soup.find_all("a", href=True) to get anchors that have an href attribute.

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.