API Reference
Beautiful Soup
Python library for pulling data from HTML and XML documents with a simple parsing and traversal API.
Official Documentation ↗CompatibilityThis documentation covers version
v4.12. Check the official docs for the latest API surface.Installation
pip
pip install beautifulsoup4Methods
No methods match this filter.
Beautiful Soup is a Python library for pulling data out of HTML and XML files. It creates a parse tree that can be searched and modified, working with several parsers and providing idiomatic traversal and extraction.
Key Features
- Parsers: html.parser, lxml, html5lib
- Finders: find, find_all, select with CSS selectors
- Navigation: Parent, child, sibling traversal
- Modification: Edit tags and attributes in place
- Encoding: Automatic detection and conversion
Security notes
Quoted verbatim from the official documentation; this is not a complete threat model. 来源:https://www.crummy.com/software/BeautifulSoup/ · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:48:23.791Z.
- If it’s a security vulnerability, report it confidentially through Tidelift . (https://www.crummy.com/software/BeautifulSoup/)
FAQ
- Which parser should I use with Beautiful Soup?
- html.parser is built in and adequate for most HTML. lxml is faster and more lenient for large or malformed documents. html5lib is the slowest but most spec-compliant, ideal for tricky markup.
- How do I handle missing attributes safely?
- Use tag.get('href') which returns None if missing, rather than tag['href'] which raises KeyError. For text, check that tag is not None before calling .text.
- Is Beautiful Soup suitable for large documents?
- It loads the whole document into memory, so it is not ideal for huge files. For streaming large XML, use lxml.iterparse. For most scraping tasks, Beautiful Soup is fast and convenient.
Report a problem with this API docOpens a pre-filled issue on GitHub.