pydoc > bs4

πŸ“– NAME

bs4 – Beautiful Soup Elixir and Tonic – β€œThe Screen-Scraper’s Friend”.

πŸš€ Quick Reference

Use CaseCommandDescription
Parse HTMLsoup = BeautifulSoup(html, 'html.parser')Parse an HTML string into a BeautifulSoup object.
Parse XMLsoup = BeautifulSoup(xml, 'lxml-xml')Parse an XML string using lxml.
Find all tagssoup.find_all('a')Find all occurrences of a tag.
Find first tagsoup.find('a')Find the first occurrence of a tag.
CSS selectorsoup.select('.class')Select elements by CSS selector.
Extract textsoup.get_text()Get all text from the document.
Get attributetag['href']Get the value of an attribute.
Set attributetag['href'] = 'new_url'Set the value of an attribute.
Navigate treetag.parentAccess the parent of a tag.
Iterate childrentag.childrenIterate over direct children.
Pretty printsoup.prettify()Return indented HTML/XML string.
Modify tagnew_tag = soup.new_tag('div')Create a new tag and insert it.

πŸ“ DESCRIPTION

http://www.crummy.com/software/BeautifulSoup/

Beautiful Soup uses a pluggable XML or HTML parser to parse a (possibly invalid) document into a tree representation. Beautiful Soup provides methods and Pythonic idioms that make it easy to navigate, search, and modify the parse tree.

Beautiful Soup works with Python 3.6 and up. It works better if lxml and/or html5lib is installed.

For more than you ever wanted to know about Beautiful Soup, see the documentation: http://www.crummy.com/software/BeautifulSoup/bs4/doc/

πŸ“¦ PACKAGE CONTENTS

πŸ›οΈ CLASSES

bs4.element.Tag(bs4.element.PageElement)
BeautifulSoup

πŸ›οΈ class BeautifulSoup(bs4.element.Tag)

Constructor: BeautifulSoup(markup='', features=None, builder=None, parse_only=None, from_encoding=None, exclude_encodings=None, element_classes=None, **kwargs)

A data structure representing a parsed HTML or XML document. Most methods are inherited from PageElement or Tag.

πŸ“Œ Methods defined here

πŸ“Š Data and other attributes defined here

πŸ“œ Methods inherited from bs4.element.Tag

πŸ” Readonly properties inherited from bs4.element.Tag

πŸ”§ Data descriptors inherited from bs4.element.Tag

🧩 Data and other attributes inherited from bs4.element.Tag

πŸ“œ Methods inherited from bs4.element.PageElement

πŸ” Readonly properties inherited from bs4.element.PageElement

πŸ”§ Data descriptors inherited from bs4.element.PageElement

🧩 Data and other attributes inherited from bs4.element.PageElement

πŸ“Š DATA

πŸ”– VERSION

4.12.3

πŸ‘€ AUTHOR

Leonard Richardson (leonardr AT segfault.org)

πŸ“ FILE

/home/chedong/.local/lib/python3.10/site-packages/bs4/__init__.py

bs4
πŸ“– NAME πŸš€ Quick Reference πŸ“ DESCRIPTION πŸ“¦ PACKAGE CONTENTS πŸ›οΈ CLASSES
πŸ›οΈ class BeautifulSoup(bs4.element.Tag)
πŸ“Š DATA πŸ”– VERSION πŸ‘€ AUTHOR πŸ“ FILE

Generated by phpman v4.9.27 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-19 20:28 @216.73.216.114
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format

^_top_^