Skip to content

riodevnet/snakyscraper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🐍 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

pip install snakyscraper

Requires Python 3.7 or later


πŸ› οΈ Basic Usage

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 <h1> 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

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

scraper.open_graph()
scraper.open_graph("og:title")

scraper.twitter_card()
scraper.twitter_card("twitter:title")

πŸ”Ή Headings & Text

scraper.h1()
scraper.h2()
scraper.h3()
scraper.h4()
scraper.h5()
scraper.h6()
scraper.p()

πŸ”Ή Lists

scraper.ul()
scraper.ol()

πŸ”Ή Images

scraper.images()
scraper.image_details()

πŸ”Ή Links

scraper.links()
scraper.link_details()

πŸ” Custom DOM Filtering

Use filter() to target specific DOM elements and extract nested content.

β–Έ Single element

scraper.filter(
    element="div",
    attributes={"id": "main"},
    multiple=False,
    extract=[".title", "#description", "p"]
)

β–Έ Multiple elements

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:

scraper.filter(
    element="p",
    attributes={"class": "dark-text"},
    multiple=True,
    return_html=False
)

πŸ“¦ Output Example

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 or submit a pull request.


πŸ“„ License

MIT License Β© 2025 β€” SnakyScraper


πŸ”— Related Projects


πŸ’‘ Why SnakyScraper?

Think of it as your Pythonic sniper β€” targeting HTML content with precision and elegance.

About

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.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages