Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/samuelcaldas/simplehtmlparser
Simple HTML Parser is a lightweight Python library designed to extract content from HTML elements based on their ID or class attributes.
https://github.com/samuelcaldas/simplehtmlparser
curl html html-class html-id parser python regex
Last synced: 21 days ago
JSON representation
Simple HTML Parser is a lightweight Python library designed to extract content from HTML elements based on their ID or class attributes.
- Host: GitHub
- URL: https://github.com/samuelcaldas/simplehtmlparser
- Owner: samuelcaldas
- License: mit
- Created: 2024-06-19T17:43:27.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-06-19T17:55:28.000Z (5 months ago)
- Last Synced: 2024-10-15T19:24:32.809Z (21 days ago)
- Topics: curl, html, html-class, html-id, parser, python, regex
- Language: Python
- Homepage:
- Size: 5.86 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Simple HTML Parser
Simple HTML Parser is a lightweight Python library designed to extract content from HTML elements based on their ID or class attributes.
## Features
- Fetch inner content from HTML elements by ID or class.
- Easy-to-use interface with clear error messages.
- Unit tests included for reliability.## Installation (WIP)
To install Simple HTML Parser, simply run:
```bash
pip install simple-html-parser
```## Usage
Import the `HtmlParser` class and initialize it with the URL of the HTML page you want to parse:
```python
from html_parser import HtmlParser# Initialize HtmlParser with URL
parser = HtmlParser('http://example.com')
```To extract content by ID:
```python
content_by_id = parser.with_id('example-id').get_inner_content()
print(f'Content by ID: {content_by_id}')
```To extract content by class:
```python
content_by_class = parser.with_class('example-class').get_inner_content()
print(f'Content by Class: {content_by_class}')
```## Testing
To run the unit tests, execute:
```bash
python -m unittest test_html_parser.py
```## Contributions
Contributions are welcome! Please submit a pull request or open an issue if you have any suggestions or improvements.
## License
Simple HTML Parser is released under the MIT License. See the [LICENSE](LICENSE) file for more details.