Skip to main content

A fast Python API wrapper for rule34 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
max_retries int 5 Max retries for rate limits (429)

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-1.0.2.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

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

rule34scraper-1.0.2-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for rule34scraper-1.0.2.tar.gz
Algorithm Hash digest
SHA256 9fab2fc3498b451afe43ad8eb3e1731673f3b1a53c682392af457ef285d0ade5
MD5 32c9f1abfcfc3ccc5d5ba0355a83cca8
BLAKE2b-256 2dcc3f221bda1e1c864c7d432f84d16dfaf7a36376c8cc90f70b24be5306f5a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for rule34scraper-1.0.2.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-1.0.2-py3-none-any.whl.

File metadata

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

File hashes

Hashes for rule34scraper-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5771257855a061117781a6dc0add7c61fe9545f6816516b38f0410cd07b9ead3
MD5 193ec98e266887075add03cca8951f02
BLAKE2b-256 3f9e40330afdb543dd359d40c260f800598868ddf56c0014496e097eebf2a1b2

See more details on using hashes here.

Provenance

The following attestation bundles were made for rule34scraper-1.0.2-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