Beautiful Soup
Python HTML/XML parsing and screen-scraping library for web data extraction.
2. Maintained
crummy.com/software/BeautifulSoup/bs4/3. Used by agents' projects
Dependency in 133 public GitHub projects set up for AI coding agents that we scanned (2.1%).
4. Agent access
Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.
From the package registry and GitHub, checked daily. Tap a verdict to see its source.How we checkedReport an error
What Beautiful Soup does
Beautiful Soup is a layer of simple search-and-edit methods that sits on top of parsers like lxml and html5lib, built for quick jobs on messy pages you did not write; its site says it has been saving programmers time on them since 2004.
Beautiful Soup popularity
Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated
How Beautiful Soup is used
- Beautiful Soup is a dependency in 133 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (8.2% of the 1,623 Python ones), #1 of 141 in scraping, browsers and parsing.
- Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 1,613; those are left out of every share on this page.
- The most used alternative in our scan is lxml (79 projects).
- Projects that use it most often also use Requests (73.7%), python-dotenv (67.7%), FastAPI (50.4%).
- It is more common in projects set up for OpenClaw (5.1%) than for OpenAI Codex (1.7%).
By coding agent
Often used with
Beautiful Soup in practice
Strengths
The site's examples are phrased the way you would say them out loud, such as all links of class <code>externalLink</code> or all links whose URLs match a domain. The library "does the tree traversal stuff for you."
Incoming documents are converted to Unicode and outgoing ones to UTF-8. The site says you normally do not have to think about encodings.
Because it sits on top of lxml or html5lib, the site says you can "try out different parsing strategies or trade speed for flexibility." The site does not compare the parsers.
Besides <code>pip install</code>, the site says the MIT license lets you download the tarball and drop the <code>bs4/</code> directory into almost any Python application.
Watch out for
Sometimes a document does not specify its encoding and Beautiful Soup cannot detect one. In that case you have to specify the original encoding yourself.
The site says Beautiful Soup 3 is "the BeautifulSoup package on pip" and does not support Python 3. It also warns that the <code>beautifulsoup</code> name will be reclaimed. When that happens, Python 2 code still on version 3 will break.
Beautiful Soup 4 supports Python 3.7 and later. The site tells anyone with active Beautiful Soup 3 projects to move to version 4 as part of their Python 3 conversion.
More about Beautiful Soup
Head to head
- Beautiful Soup vs lxml used together in 56 projects
Packages around it
- requests: HTTP client
- python-dotenv: .env config loader
- pydantic: Data validation
- numpy: Numerical arrays
- fastapi: Web API framework
- uvicorn: ASGI server
More in Scraping, browsers and parsing
Alternatives
Beautiful Soup This page
High-performance XML and HTML processing library combining libxml2/libxslt with Python.
High-level Python API for automating browser testing and web scraping.
Official Python bindings for browser automation and web scraping.
HTML parser based on WHATWG specification for parsing and processing HTML.
Get started
Install it.
pip install beautifulsoup4Rules for your agent
## Beautiful Soup
- The site's install command is `pip install beautifulsoup4`. The `BeautifulSoup` package on pip is Beautiful Soup 3, which does not support Python 3, so do not add it as a dependency.
- Target Python 3.7 or later. Beautiful Soup 4 dropped Python 2 support on January 1, 2021.
- Pick the underlying parser (lxml or html5lib) on purpose. The site frames the choice as trying "different parsing strategies" or trading "speed for flexibility".
- If a document does not specify an encoding and Beautiful Soup cannot detect one, pass the original encoding explicitly.
- Expect parsed documents as Unicode and output as UTF-8.
- When porting Beautiful Soup 3 code, migrate it to Beautiful Soup 4 as part of the Python 3 conversion.
- File bugs on Launchpad. Report security vulnerabilities confidentially through Tidelift.