Skip to main content

BeautifulSoup Element Parser for Swarmauri.

Project description

Swarmauri Logo

PyPI - Downloads Hits PyPI - Python Version PyPI - License PyPI - swarmauri_parser_beautifulsoupelement


Swarmauri Parser Beautifulsoupelement

A specialized parser that utilizes BeautifulSoup to extract specific HTML elements and their content from HTML documents. The parser accepts HTML strings only and produces a list of Document objects that capture both the HTML snippet for each matched element and metadata (the element tag and its index within the input).

Installation

Choose the installation workflow that fits your project:

pip

pip install swarmauri_parser_beautifulsoupelement

Poetry

poetry add swarmauri_parser_beautifulsoupelement

uv

If you have not installed uv yet, grab it with the official installer:

curl -LsSf https://astral.sh/uv/install.sh | sh

Once uv is available, add the parser to your environment:

uv pip install swarmauri_parser_beautifulsoupelement

Usage

The BeautifulSoupElementParser allows you to extract specific HTML elements from HTML content:

from swarmauri_parser_beautifulsoupelement import BeautifulSoupElementParser

# Create a parser instance to extract paragraphs
parser = BeautifulSoupElementParser(element="p")

# HTML content to parse
html_content = "<div><p>First paragraph</p><p>Second paragraph</p></div>"

# Parse the content (input must be a string)
documents = parser.parse(html_content)

# Access the extracted elements and metadata
for doc in documents:
    print(doc.content)     # Prints each paragraph element, including the surrounding <p> tag
    print(doc.metadata)    # {'element': 'p', 'index': 0}, {'element': 'p', 'index': 1}, ...

Note: BeautifulSoupElementParser.parse raises a ValueError if the provided data argument is not a string. Ensure that you pass HTML content as a text string before invoking the parser.

Want to help?

If you want to contribute to swarmauri-sdk, read up on our guidelines for contributing that will help you get started.

Project details


Download files

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

Source Distribution

Built Distribution

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

File details

Details for the file swarmauri_parser_beautifulsoupelement-0.9.0.dev46.tar.gz.

File metadata

  • Download URL: swarmauri_parser_beautifulsoupelement-0.9.0.dev46.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for swarmauri_parser_beautifulsoupelement-0.9.0.dev46.tar.gz
Algorithm Hash digest
SHA256 531b345a495e774094eb3a08f925b8aeaab54cbdcae5ecf39ab2b83d2ce65f99
MD5 74d003a69e4fc7e76641031fdb98ca31
BLAKE2b-256 9b882313c638fc70f4fc90c374dc751e2b56ee82167d42a5ddd14261443b5832

See more details on using hashes here.

File details

Details for the file swarmauri_parser_beautifulsoupelement-0.9.0.dev46-py3-none-any.whl.

File metadata

  • Download URL: swarmauri_parser_beautifulsoupelement-0.9.0.dev46-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for swarmauri_parser_beautifulsoupelement-0.9.0.dev46-py3-none-any.whl
Algorithm Hash digest
SHA256 ad6364d3849c81b513e43a5d26b39c97cfdff752b5e2f2d68ecb2347f625d31a
MD5 5551401243478fd54cac18ba95ce2b07
BLAKE2b-256 b686ca40c1a57fb99009a08610e6956cc74f8361328f38dd8e420a17f4219dbe

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 Pingdom Monitoring Sentry Error logging StatusPage Status page