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.dev42.tar.gz.

File metadata

  • Download URL: swarmauri_parser_beautifulsoupelement-0.9.0.dev42.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.dev42.tar.gz
Algorithm Hash digest
SHA256 491a078824afae6f0a9e77d31a7f98dfae47323e35707b8ba6b1658b6b040892
MD5 7d0431d175b3e18b1b5872c607d217ec
BLAKE2b-256 3fb196a3cee8aacc9f0c2921498f0579847259467f9b68bd8729f70812cd7c08

See more details on using hashes here.

File details

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

File metadata

  • Download URL: swarmauri_parser_beautifulsoupelement-0.9.0.dev42-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.dev42-py3-none-any.whl
Algorithm Hash digest
SHA256 b9142cc9a68c3535a484ec844bdaee60e39d1e25ad157f296b75b8719426a482
MD5 9ce26bad9c09eb9a0b87c0dadc80fc86
BLAKE2b-256 476fe27fff10540c79a8d66fb905a972de8873332d96cac4e796df5a709e20ed

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