Skip to main content

Fully asynchronous read-only API wrapper for 2ch.hk (dvach)

Project description

License Downloads PyPi Python

Fully asynchronous read-only API wrapper for 2ch.hk (dvach, Двач)

Requirements

  • Python 3.5+

Install with pip

$ pip3 install aio2ch

Build from source

$ git clone https://github.com/wkpn/aio2ch
$ cd ./aio2ch
$ python3 setup.py install

Usage

>>> from aio2ch import Api
>>> api = Api()

Get all boards

>>> boards = await api.get_boards()

>>> boards
[<Board name: Фагготрия, id: fag>, ... ]

In addition we can get status for each method. This is useful for debug purposes or if retries are needed

>>> status, boards = await api.get_boards(return_status=True)

>>> status
200

>>> boards
[<Board name: Фагготрия, id: fag>, ... ]

Get all threads from a board

>>> threads = await api.get_board_threads(board='b')

>>> threads
[<Thread 180981319>, ... ]

Get top threads from a board sorted by method (views, score or posts_count)

>>> top_threads = await api.get_top_board_threads(board='b', method='views', num=3)

>>> top_threads
[<Thread 180894312>, <Thread 180946622>, <Thread 180963318>]

Get all thread’s posts (thread is an instance of Thread)

>>> thread_posts = await api.get_thread_posts(thread=thread)

>>> thread_posts
[<Post 180894312>, ... ]

Get all media in all thread’s posts (images, webm and so on)

>>> thread_media = await api.get_thread_media(thread=thread)

>>> thread_media
[<File name:15336559148500.jpg, path:/b/src/180979032/15336559148500.jpg, size:19>, ... ]

Download all thread media

>>> await api.download_thread_media(files=thread_media, save_to='./downloads/')

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

aio2ch-1.4.3.1.tar.gz (4.2 kB view hashes)

Uploaded Source

Built Distribution

aio2ch-1.4.3.1-py3-none-any.whl (5.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page