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

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.1.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-1.0.1-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rule34scraper-1.0.1.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-1.0.1.tar.gz
Algorithm Hash digest
SHA256 882a1a338cca23820d7b2be94274694607a3c5a3cff0162244359ff98578e5ce
MD5 b34773a1f9985b4601d395e1fc9b9296
BLAKE2b-256 dbb3d82517b3aa57a88ee71b675b770e0b5f395e57fb115b3733d5d4feda5175

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: rule34scraper-1.0.1-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-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 77b7b3975e8db4fe93a33f46e07012fee918b0bb7a861e6e8e09c8e1d3013e01
MD5 c52d2c920dd4bf121ac91216bd6703ee
BLAKE2b-256 1b7927bd6ce849111aed1c4eeedefcb8ed38d254e8556d8cc201f7fb7c8b0167

See more details on using hashes here.

Provenance

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