You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

pyawful

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pyawful

Pay ten dollars to get access to a dead forum.

0.5.0
pipPyPI
Maintainers
1

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.

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.