Giter VIP home page Giter VIP logo

python-jaccount-cli's Introduction

Python Jaccount CLI

A small plugin to help use jaccount login in cli programs.

Example

import asyncio
from getpass import getpass

from jaccount_cli import JaccountCLIAsyncIO


async def main():
    async with JaccountCLIAsyncIO("https://umjicanvas.com/login/openid_connect") as cli:
        await cli.init()

        captcha_ascii = cli.captcha_generate_ascii()
        print()
        print(captcha_ascii)
        print()
        # or you can use
        # cli.captcha_show_external()

        captcha = input("Please enter the shown captcha: ")
        username = input("Please enter jaccount username: ")
        password = getpass("Please enter password: ")

        await cli.login(username, password, captcha)

        async with cli.session.get(
            "https://umjicanvas.com/api/v1/users/self/favorites/courses?include[]=term&exclude[]=enrollments",
            headers={"Accept": "application/json"},
        ) as response:
            print(await response.text())

        # print cookies
        cookies = cli.get_cookies()
        for key, cookie in cookies.items():
            print('Key: "%s", Value: "%s"' % (cookie.key, cookie.value))


if __name__ == "__main__":
    asyncio.get_event_loop().run_until_complete(main())

License

MIT

python-jaccount-cli's People

Contributors

tc-imba avatar boyanzh avatar

Stargazers

Linsy avatar ctrate avatar Haifeng Jia avatar  avatar

Watchers

James Cloos avatar  avatar  avatar

Forkers

linsyking

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.