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.4.0.tar.gz (64.3 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.4.0-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pyawful-0.4.0.tar.gz
Algorithm Hash digest
SHA256 7651d906deef22f24ee3831ff7fce00273d09db50d76c80a94a9bc7e58620b06
MD5 6484b1cd3b6bcdf5e984adb734b69919
BLAKE2b-256 f986827d9730b1c72da43d8141304e6cd8c08a17c5c4d840e03b02041c5939e2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyawful-0.4.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.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f11e13eeb838d317d165485bcded4d0331e3bdde00c167bb87fe5f5ec427a409
MD5 1d829524d157765947ee8a9a8d50d2b5
BLAKE2b-256 ffd822f595db5796c63d9d1b61b70abf0e0c958d3932f9fbde66f71ac4dc3173

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