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.5.0.tar.gz (73.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.5.0-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pyawful-0.5.0.tar.gz
Algorithm Hash digest
SHA256 0866dfc47afb255b31cadd44b380310d53d06062e7dde86f27b52a36d3a94e29
MD5 414e5301f557d271bdd1d5acece79f39
BLAKE2b-256 ae0bf5d201d9d4de11261b62fc561cd0bcbde1290fc1cc1d9701f936e659e404

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pyawful-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5570a1f508d2c9f7d0d46373486c46d36b83508d9883f781dd8b71295fa2826c
MD5 87ed2bb80d653fd128c032d4bfadcf57
BLAKE2b-256 f0ecd528a5a12ed9160221932bab50083f12ba720ddae02bedca450bb78a82a9

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