Skip to main content

A fast Python API wrapper for rhi.by image board

Project description

rule34scraper

A fast Python API wrapper for booru-style image boards using selectolax (Lexbor engine).

Installation

pip install rule34scraper

Usage

Basic Usage

from rule34scraper import R34Client

with R34Client() as client:
    # Search posts by tags
    posts, tags = client.get_posts(tags="landscape", page=1)
    
    for post in posts:
        print(f"ID: {post.id}, Score: {post.score}, Rating: {post.rating}")
    
    # Get post details
    details = client.get_post_details(posts[0].id)
    print(f"Image: {details.image_url}")
    print(f"Size: {details.width}x{details.height}")
    
    # Download image
    client.download_post(details, directory="downloads/")

Custom Base URL

from rule34scraper import R34Client

# Use a different booru site
client = R34Client(
    base_url="https://example.com/index.php",
    posts_per_page=42,
    timeout=60.0,
)

# Custom headers
client = R34Client(
    base_url="https://example.com/index.php",
    headers={"Cookie": "session=abc123"},
)

Async Client

import asyncio
from rule34scraper import AsyncR34Client

async def main():
    async with AsyncR34Client() as client:
        posts, tags = await client.get_posts(tags="portrait", page=1)
        details = await client.get_post_details(posts[0].id)
        print(f"Image: {details.image_url}")

asyncio.run(main())

User Profiles

with R34Client() as client:
    profile = client.get_user_profile("username")
    print(f"User: {profile.username} (ID: {profile.id})")
    print(f"Level: {profile.level}")
    print(f"Posts: {profile.post_count}")
    print(f"Favorites: {profile.favorite_count}")

Models

  • Post - Thumbnail entry from search results
  • PostDetails - Full post metadata (image URL, dimensions, tags, comments)
  • Tag - Tag with name, count, and type
  • PostComment - User comment on a post
  • UserProfile - User profile with stats and recent posts

Configuration Options

Parameter Type Default Description
base_url str https://rule34.xxx/index.php Base URL for the API
timeout float 30.0 Request timeout in seconds
posts_per_page int 42 Posts per page for pagination
headers dict Browser-like headers Custom HTTP headers

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rule34scraper-0.1.0.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rule34scraper-0.1.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file rule34scraper-0.1.0.tar.gz.

File metadata

  • Download URL: rule34scraper-0.1.0.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rule34scraper-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ac3e3509b6bfe9bc2b5bbb15971855df8325e9f5f601a7c75bbf80bfd467b9f1
MD5 b31cc3f5e459a095e39a8d938fe66a0a
BLAKE2b-256 7726269b3fdc1e17935fe41e86aaf720363b9e3f61da235dc79d81c25db0885e

See more details on using hashes here.

Provenance

The following attestation bundles were made for rule34scraper-0.1.0.tar.gz:

Publisher: python-publish.yml on whatimdoingwithmylife-sudo/rule34scraper

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rule34scraper-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: rule34scraper-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rule34scraper-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2543390813cff7dac77d03b18c485340b1a3aca0ce35c889970c554fc5cb9e39
MD5 51db7e6e9d5f708ed86d5a8b1396b327
BLAKE2b-256 59a481a662f41c3dd9e89588bb719ad5d6927b135328e449c0aa6e9ac373fbb5

See more details on using hashes here.

Provenance

The following attestation bundles were made for rule34scraper-0.1.0-py3-none-any.whl:

Publisher: python-publish.yml on whatimdoingwithmylife-sudo/rule34scraper

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page