Skip to main content

Logo

License Changelog Downloads PyPi Python

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

Requirements

Install with pip

$ pip3 install aio2ch

Build from source

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

Usage

Simple usage (in this case client.close() must be called when client is no longer needed)

>>> from aio2ch import Api
>>> client = Api()
>>> ...
>>> await client.close()

Or you can use it as a context manager

>>> async with Api() as client:
...     boards = await client.get_boards()
...     ...

Get all boards

>>> boards = await client.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 client.get_boards(return_status=True)

>>> status
200

>>> boards
(<Board name='Фагготрия', id='fag'>, ... )

Get all threads from a board

>>> threads = await client.get_board_threads(board="b")

>>> threads
(<Thread num='180981319'>, ... )

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

>>> top_threads = await client.get_top_board_threads(board="b", method="views", num=3)

>>> top_threads
(<Thread num='180894312'>, <Thread num='180946622'>, <Thread num='180963318'>)

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

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

>>> thread_posts
(<Post num='180894312'>, ... )

Get all thread’s posts by url

>>> thread_posts = await client.get_thread_posts(thread="https://2ch.hk/test/res/30972.html")

>>> thread_posts
(<Post num='30972'>, ... )

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

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

>>> thread_media
(<File name='15336559148500.jpg', path='/b/src/180979032/15336559148500.jpg', size='19'>, ... )

Get specific thread media

>>> images_and_videos = await client.get_thread_media(thread, media_type=(Image, Video))

>>> images_and_videos
(<Image name=...>, <Video name=...>, ...)

>>> just_images = await client.get_thread_media(thread, media_type=Image)

>>> just_images
(<Image name=...>, ...)

Download all thread media

>>> await client.download_thread_media(files=thread_media, save_to="./downloads")

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aio2ch-3.2.1.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aio2ch-3.2.1-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file aio2ch-3.2.1.tar.gz.

File metadata

  • Download URL: aio2ch-3.2.1.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.2

File hashes

Hashes for aio2ch-3.2.1.tar.gz
Algorithm Hash digest
SHA256 7db837c8b8781eaa951256211346b84540fc5280389816293cd4a6a9ab498b91
MD5 35bbf14326b4aba3d466c96232eddbe3
BLAKE2b-256 3ecea2fdcfeb488762e2d11b7dbb091f44a5e97c97cc9c4497e9f43b90dda340

See more details on using hashes here.

File details

Details for the file aio2ch-3.2.1-py3-none-any.whl.

File metadata

  • Download URL: aio2ch-3.2.1-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.2

File hashes

Hashes for aio2ch-3.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5426cdc70625abb61f37e8aff0d182857732d295f88b56d3ca1c9acbfb2c61d2
MD5 03b27a59b8f07f00594b45af1141f9a9
BLAKE2b-256 9a753808d2614e98a2b85ad69efb7e415bcdbe7066b82dccb5a2ead6fc0d11d7

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

3.2.1 This release

2 files

3.2.0

2 files

3.1.2

2 files

3.1.1

2 files

3.1.0

3 files

3.0.0

2 files

2.1.2

2 files

2.1.1

2 files

2.1.0

2 files

2.0.3

2 files

2.0.2

2 files

2.0.1

2 files

2.0

2 files

1.4.3.1

2 files

1.4.3

2 files

1.4.2

2 files

1.4.1

2 files

1.4

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page