skillfed

w3lib

Library of web-related functions

w3lib v2.4.1 9.3M downloads/30d#1,551 on PyPI418
Permissive license BSD-3-Clause Active released

What it is and what it does

w3lib is a utility library for web-related tasks commonly needed in web scraping, HTTP clients, and HTML processing. It provides functions to strip HTML tags and comments, extract base URLs from HTML snippets, translate HTML entities, convert raw HTTP headers to dictionaries, construct HTTP authentication headers, normalize URLs according to browser rules, and parse query parameters from URLs.

The library has no runtime dependencies and installs cleanly as a pure Python wheel. It is actively maintained, supports current Python versions (3.10–3.14), and runs on both CPython and PyPy. With monthly downloads in the millions and stable status, it is a widely-used component in web automation and data extraction workflows.

Use it for:

  • Strip HTML tags and comments from web page snippets before text analysis or storage
  • Normalize and sanitize URLs in web scrapers to avoid duplicate requests or broken links
  • Parse and manipulate HTTP headers when building custom HTTP clients or middleware
  • Extract base URLs from HTML documents to resolve relative links correctly
  • Construct HTTP Basic Authentication headers for requests to protected resources

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

w3lib provides utility functions for common web tasks: parsing and manipulating HTML, extracting URLs and their components, handling HTTP headers and authentication, and normalizing URLs according to browser standards.

Yes. w3lib is a mature, zero-dependency utility library with active maintenance, no known vulnerabilities, permissive licensing, and broad Python version support. Install it if you need reliable, battle-tested helpers for URL normalization, HTML parsing, or HTTP header manipulation in web scraping or HTTP client code.

Install

w3lib on PyPI

pip

pip install w3lib

uv

uv add w3lib

poetry

poetry add w3lib

Installing w3lib

Before you install

Low friction installation with no runtime dependencies. Active maintenance with recent releases; last commit 2026-08-14 and latest release 2026-03-20. Supports modern Python versions (3.10 through 3.14) on both CPython and PyPy.

License in practice

BSD-3-Clause permissive license allows use in commercial and open-source projects with minimal restrictions—include a copy of the license and attribution.

Quickstart

pip install w3lib

from w3lib.html import remove_tags, extract_base_url
from w3lib.url import sanitize_url

html = '<p>Hello</p>'
text = remove_tags(html)
url = sanitize_url('http://example.com/path')

Requires Python 3.10 or later.

Verify before relying

  • Whether the package handles HTML5 entity decoding or only a subset of HTML entities
  • Performance characteristics when processing large HTML documents or many URLs
  • Whether URL sanitization matches all major browser behaviors or a subset
  • How long the package has been in active use and maintenance history

Package facts

License BSD-3-Clause (permissive)
Python support supports the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance actively maintained — 147 days since the last release
Last repo commit
First released
Downloads 9,275,745/month — #1,551 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: w3lib-2.4.1-py3-none-any.whl

Development Status :: 5 - Production/StableIntended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Internet :: WWW/HTTPTopic :: Software Development :: Libraries :: Python Modules

Tags

html parsing utilitiesurl normalizationhttp header handlingweb scraping helpershtml tag removalurl extraction
web-utilitieshtml-parsingurl-handling

More Python Modules packages