Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Configurable HTML Parser Wrappers for BeautifulSoup and Resiliparse #47

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

silentninja
Copy link

Fixes #43

This PR introduces wrapper classes that provide a uniform API for common operations across two HTML parsers: BeautifulSoup and Resiliparse. The goal is to simplify switching between the parsers and ensure consistency in usage patterns.

Additionally, the PR adds support for configuring the HTML parser wrapper at runtime by introducing a new --html_parser option when submitting a Spark job. This allows users to specify their preferred parser dynamically during execution.

@silentninja
Copy link
Author

We can enhance this further by adding support for third-party HTML parser wrappers.

The idea is to allow users to pass the path to a custom wrapper module as a runtime argument. This approach would enable developers to use community-contributed libraries without requiring modifications to the existing codebase.

Proposed Implementation

  • Use Python's importlib to dynamically load the custom wrapper module at runtime.
  • Define an abstract base class that all custom wrapper classes must extend to ensure a consistent interface.
  • Add runtime validation to verify that the custom wrapper class correctly implements all required methods and adheres to the expected interface.

It would be worth considering this when there is an interest in third-party wrappers

@wumpus
Copy link
Member

wumpus commented Dec 30, 2024

I like the idea of a wrapper that makes it easy to switch parsers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Example using Resiliparse's HTML parser or text extractor
2 participants