Skip to main content

Pay ten dollars to get access to a dead forum.

Project description

pyawful

Spend $10 to interact with a dead forum from Python.

[!CAUTION] Using this library without being funny may lead to your account being permanently banned.

Let's be honest, here: That's probably a net positive.

Installation

This package is available via PyPi as pyawful and can be installed via your package manager of choice.

Usage

import os

from pyawful import AuthenticatedAwfulSession

USERNAME = os.environ["SA_USERNAME"]
PASSWORD = os.environ["SA_PASSWORD"]

with AuthenticatedAwfulSession(USERNAME, PASSWORD) as client:
    response = client.get_forum_threads(273)

    for thread in response.threads:
        print(thread.title)

Caching Authentication Session

[!WARNING] Ignore this advice if you want to pay $10 again

Limit the number of sessions you create - if you're making lots of requests or otherwise doing something regularly you should persist the session cookies and restore them.

from datetime import datetime
import json
import os

from pyawful import AuthenticatedAwfulSession, AwfulCookies

USERNAME = os.environ["SA_USERNAME"]
PASSWORD = os.environ["SA_PASSWORD"]

session = AuthenticatedAwfulSession(USERNAME, PASSWORD)

try:
    with open("./session.json", "r") as session_file:
        cached_session = json.load(session_file)
        cookies = AwfulCookies(**cached_session["cookies"])
        expiration = datetime.fromtimestamp(cached_session["expiration"])
        session.resume_session(cookies, expiration)
except Exception:
    pass

with session as client:
    cookies = session.get_cookies()
    expiration = session.get_expiration().timestamp()
    with open("./session.json", "w") as session_file:
        json.dump(
            { "cookies": cookies, "expiration": expiration },
            session_file
        )

License

Licensed under the MIT License.

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

pyawful-0.3.0.tar.gz (28.9 kB view details)

Uploaded Source

Built Distribution

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

pyawful-0.3.0-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

Details for the file pyawful-0.3.0.tar.gz.

File metadata

  • Download URL: pyawful-0.3.0.tar.gz
  • Upload date:
  • Size: 28.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.5.7

File hashes

Hashes for pyawful-0.3.0.tar.gz
Algorithm Hash digest
SHA256 491d0bcdf582c9f893eff6cf52c67dd49d0bd5d515e399160c5ac37fd3336254
MD5 ec9fdf9b8061cbe6f29873f06595965c
BLAKE2b-256 94216117ab56dbae4c3937cd70e2b361f4a0208c711ea4aac0e1067b9ae0241b

See more details on using hashes here.

File details

Details for the file pyawful-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: pyawful-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 13.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.5.7

File hashes

Hashes for pyawful-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 444a3ea62ff9a8a01692f327b7fb9abf0eaab2fb131a6a7847c9828dbee1119b
MD5 bc5996b427efc77ec2f0fb360d45b0a1
BLAKE2b-256 833283f2ac40b2ee026de5473e3802c3b780fcf0465b019af3667035b2b35507

See more details on using hashes here.

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