Metadata-Version: 2.5
Name: habraloader
Version: 1.0.0
Summary: A fast and lightweight library for downloading articles and their images from Habr.
License-File: LICENSE
Requires-Python: >=3.10
Requires-Dist: beautifulsoup4>=4.14.2
Requires-Dist: requests>=2.32.5
Description-Content-Type: text/markdown

<p align="center">
  <img src="resources/icon.png" width="150" alt="Habraloader">
  <br>
  <b>Habraloader</b>
</p>
<p align="center">
  <br>
  <b>Habraloader is a lightweight Python library for parsing articles and downloading embedded media from Habr. It extracts essential metadata (title, author, publication date), retrieves the main body content in both HTML and plain text formats, and provides built-in utilities to download all article images directly to your local filesystem.</b>
</p>

# Features
1. **Article Metadata Parsing:** Extract article ID, title, author username, and ISO publication timestamp.
2. **Dual Content Extraction:** Retrieve full article content in HTML string format or clean plain text.
3. **Image URL Extraction:** Automatically discover unique image URLs from `<img>` and `<source>` tags.
4. **Batch Image Downloader:** Download all images associated with an article into organized output directories.
5. **Session Management:** Built-in connection management using `requests.Session` with realistic User-Agent headers.

# Quickstart
Below is a complete example showing how to initialize the parser, fetch an article by its ID, save it as a Markdown file, and download its images:
```python
from habraloader import HabrParser

parser = HabrParser()
article = parser.get_article(668378)

print(f"Title: {article.title}")
print(f"Author: {article.author}")

# Save article to a Markdown file
file_path = article.save_md()
print(f"Article successfully saved to: {file_path}")

# Download images (if any)
saved_files = article.save_images(target_dir="downloaded_images")
print(f"Successfully saved images: {len(saved_files)}")
```