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

File metadata

  • Download URL: swarmauri_parser_beautifulsoupelement-0.9.0.dev32.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","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.dev32.tar.gz
Algorithm Hash digest
SHA256 555d3d478fb15cede1f6fda4e4351e0e67775e7824e3c3971097b93a6675d57f
MD5 d97f3a76d518c9351d94fb1a5112a780
BLAKE2b-256 13f4965e8361447b99bfb9b6982d76595eb5b3b92c1264c84adef2a2de3b238c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: swarmauri_parser_beautifulsoupelement-0.9.0.dev32-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","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.dev32-py3-none-any.whl
Algorithm Hash digest
SHA256 24032b06145d65ecd25e11995c04ae9614250aad32949634f9f780cba86c50a1
MD5 7cb6327417b40cf4e8b2e34a68aa07b7
BLAKE2b-256 102e9f54040fbe3e589c39665264a46a403f32d90d9a6cf27464e285fdeddef2

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