https://github.com/riodevnet/snakyscraper
SnakyScraper is a lightweight and Pythonic web scraping toolkit built on top of BeautifulSoup and Requests. It provides an elegant interface for extracting structured HTML and metadata from websites with clean, direct outputs.
https://github.com/riodevnet/snakyscraper
python scraper scraping
Last synced: 3 months ago
JSON representation
SnakyScraper is a lightweight and Pythonic web scraping toolkit built on top of BeautifulSoup and Requests. It provides an elegant interface for extracting structured HTML and metadata from websites with clean, direct outputs.
- Host: GitHub
- URL: https://github.com/riodevnet/snakyscraper
- Owner: riodevnet
- License: mit
- Created: 2025-06-21T05:39:14.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-08-15T08:00:13.000Z (11 months ago)
- Last Synced: 2026-03-28T00:42:33.153Z (3 months ago)
- Topics: python, scraper, scraping
- Language: Python
- Homepage: https://pypi.org/project/snakyscraper/
- Size: 3.91 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ๐ SnakyScraper
**SnakyScraper** is a lightweight and Pythonic web scraping toolkit built on top of BeautifulSoup and Requests. It provides an elegant interface for extracting structured HTML and metadata from websites with clean, direct outputs.
> Fast. Accurate. Snake-style scraping. ๐๐ฏ
---
## ๐ Features
- โ
Extract metadata: title, description, keywords, author, and more
- โ
Built-in support for Open Graph, Twitter Card, canonical, and CSRF tags
- โ
Extract HTML structures: `h1`โ`h6`, `p`, `ul`, `ol`, `img`, links
- โ
Powerful `filter()` method with class, ID, and tag-based selectors
- โ
`return_html` toggle to return clean text or raw HTML
- โ
Simple return values: string, list, or dictionary
- โ
Powered by BeautifulSoup4 and Requests
---
## ๐ฆ Installation
```bash
pip install snakyscraper
```
> Requires Python 3.7 or later
---
## ๐ ๏ธ Basic Usage
```python
from snakyscraper import SnakyScraper
scraper = SnakyScraper("https://example.com")
# Get the page title
print(scraper.title()) # "Welcome to Example.com"
# Get meta description
print(scraper.description()) # "This is the example meta description."
# Get all
elements
print(scraper.h1()) # ["Welcome", "Latest News"]
# Extract Open Graph metadata
print(scraper.open_graph()) # {"og:title": "...", "og:description": "...", ...}
# Custom filter: find all div.card elements and extract child tags
print(scraper.filter(
element="div",
attributes={"class": "card"},
multiple=True,
extract=["h1", "p", ".title", "#desc"]
))
```
---
## ๐งช Available Methods
### ๐น Page Metadata
```python
scraper.title()
scraper.description()
scraper.keywords()
scraper.keyword_string()
scraper.charset()
scraper.canonical()
scraper.content_type()
scraper.author()
scraper.csrf_token()
scraper.image()
```
### ๐น Open Graph & Twitter Card
```python
scraper.open_graph()
scraper.open_graph("og:title")
scraper.twitter_card()
scraper.twitter_card("twitter:title")
```
### ๐น Headings & Text
```python
scraper.h1()
scraper.h2()
scraper.h3()
scraper.h4()
scraper.h5()
scraper.h6()
scraper.p()
```
### ๐น Lists
```python
scraper.ul()
scraper.ol()
```
### ๐น Images
```python
scraper.images()
scraper.image_details()
```
### ๐น Links
```python
scraper.links()
scraper.link_details()
```
---
## ๐ Custom DOM Filtering
Use `filter()` to target specific DOM elements and extract nested content.
#### โธ Single element
```python
scraper.filter(
element="div",
attributes={"id": "main"},
multiple=False,
extract=[".title", "#description", "p"]
)
```
#### โธ Multiple elements
```python
scraper.filter(
element="div",
attributes={"class": "card"},
multiple=True,
extract=["h1", ".subtitle", "#meta"]
)
```
> The `extract` argument accepts tag names, class selectors (e.g., `.title`), or ID selectors (e.g., `#meta`).
> Output keys are automatically normalized:
> `.title` โ `class__title`, `#meta` โ `id__meta`
#### โธ Clean Text Output
You can also disable raw HTML output:
```python
scraper.filter(
element="p",
attributes={"class": "dark-text"},
multiple=True,
return_html=False
)
```
---
## ๐ฆ Output Example
```python
scraper.title()
# "Welcome to Example.com"
scraper.h1()
# ["Main Heading", "Another Title"]
scraper.open_graph("og:title")
# "Example OG Title"
```
---
## ๐ค Contributing
Contributions are welcome!
Found a bug or want to request a feature? Please open an [issue](https://github.com/riodevnet/snakyscraper/issues) or submit a pull request.
---
## ๐ License
MIT License ยฉ 2025 โ SnakyScraper
---
## ๐ Related Projects
- [BeautifulSoup4](https://www.crummy.com/software/BeautifulSoup/)
- [Requests](https://docs.python-requests.org/)
- [lxml](https://lxml.de/)
---
## ๐ก Why SnakyScraper?
> Think of it as your Pythonic sniper โ targeting HTML content with precision and elegance.