Skip to main content

Beautiful Soup is a library that makes it easy to scrape information from web pages. It sits atop an HTML or XML parser, providing Pythonic idioms for iterating, searching, and modifying the parse tree.

Quick start

  >>> from bs4 import BeautifulSoup
  >>> soup = BeautifulSoup("<p>Some<b>bad<i>HTML")
  >>> print soup.prettify()
  <html>
   <body>
    <p>
     Some
     <b>
      bad
      <i>
       HTML
      </i>
     </b>
    </p>
   </body>
  </html>
  >>> soup.find(text="bad")
  u'bad'

  >>> soup.i
  <i>HTML</i>

  >>> soup = BeautifulSoup("<tag1>Some<tag2/>bad<tag3>XML", "xml")
  >>> print soup.prettify()
  <?xml version="1.0" encoding="utf-8">
  <tag1>
   Some
   <tag2 />
   bad
   <tag3>
    XML
   </tag3>
  </tag1>

To go beyond the basics, comprehensive documentation is available.

Links

Building the documentation

The bs4/doc/ directory contains full documentation in Sphinx format. Run make html in that directory to create HTML documentation.

Running the unit tests

Beautiful Soup supports unit test discovery from the project root directory:

 $ nosetests
 $ python -m unittest discover -s bs4 # Python 2.7 and up

If you checked out the source tree, you should see a script in the home directory called test-all-versions. This script will run the unit tests under Python 2.7, then create a temporary Python 3 conversion of the source and run the unit tests again under Python 3.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

beautifulsoup4-4.8.0.tar.gz (170.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

beautifulsoup4-4.8.0-py3-none-any.whl (97.5 kB view details)

Uploaded Python 3

beautifulsoup4-4.8.0-py2-none-any.whl (97.7 kB view details)

Uploaded Python 2

File details

Details for the file beautifulsoup4-4.8.0.tar.gz.

File metadata

  • Download URL: beautifulsoup4-4.8.0.tar.gz
  • Upload date:
  • Size: 170.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.0 CPython/3.7.0

File hashes

Hashes for beautifulsoup4-4.8.0.tar.gz
Algorithm Hash digest
SHA256 25288c9e176f354bf277c0a10aa96c782a6a18a17122dba2e8cec4a97e03343b
MD5 2b34208b26b5c49d4c84a4b9cf78656a
BLAKE2b-256 237b37a477bc668068c23cb83e84191ee03709f1fa24d957b7d95083f10dda14

See more details on using hashes here.

File details

Details for the file beautifulsoup4-4.8.0-py3-none-any.whl.

File metadata

  • Download URL: beautifulsoup4-4.8.0-py3-none-any.whl
  • Upload date:
  • Size: 97.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.0 CPython/3.7.0

File hashes

Hashes for beautifulsoup4-4.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f040590be10520f2ea4c2ae8c3dae441c7cfff5308ec9d58a0ec0c1b8f81d469
MD5 9c1698fb128050ace2954e5e4455d3b8
BLAKE2b-256 1ab734eec2fe5a49718944e215fde81288eec1fa04638aa3fb57c1c6cd0f98c3

See more details on using hashes here.

File details

Details for the file beautifulsoup4-4.8.0-py2-none-any.whl.

File metadata

  • Download URL: beautifulsoup4-4.8.0-py2-none-any.whl
  • Upload date:
  • Size: 97.7 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.0 CPython/3.7.0

File hashes

Hashes for beautifulsoup4-4.8.0-py2-none-any.whl
Algorithm Hash digest
SHA256 05668158c7b85b791c5abde53e50265e16f98ad601c402ba44d70f96c4159612
MD5 bb5f99a86a96b06910f802ace08561c9
BLAKE2b-256 390ecfae701dc1143409adf1dc78ebc138f7c507e342e5814b1ead2a727bc900

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page