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

File metadata

  • Download URL: swarmauri_parser_beautifulsoupelement-0.9.0.dev44.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.dev44.tar.gz
Algorithm Hash digest
SHA256 45cc224fedc71bf3c210d53cd77db625eddd4047336337e3b222e1210ea8a49c
MD5 f24809c4009f12455729031116d8306b
BLAKE2b-256 e7f63f8feff7afff7b701d64245401208f4654bae760a7777fb487017ff3f385

See more details on using hashes here.

File details

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

File metadata

  • Download URL: swarmauri_parser_beautifulsoupelement-0.9.0.dev44-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.dev44-py3-none-any.whl
Algorithm Hash digest
SHA256 169613291d1d861837c1440a5c1da9029858ecb9cf2f9173ccac489e5f243f31
MD5 c1b2518a3e57b2459745fc38c3040fd2
BLAKE2b-256 078c8efe0e804998461fbcd60707f8d7c1c1f9d72da3f9f3b92b5c5712766120

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