- Notifications
You must be signed in to change notification settings - Fork0
Fully asynchronous read-only API wrapper for 2ch.hk (dvach, Двач)
License
wkpn/aio2ch
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Fully asynchronous read-only API wrapper for 2ch.hk (dvach, Двач)
$ pip3 install aio2ch
$ git clone https://github.com/wkpn/aio2ch$cd ./aio2ch$ python3 setup.py install
Simple usage (in this caseclient.close()
must be called when client is no longer needed)
>>>fromaio2chimportApi>>>client=Api()>>> ...>>>awaitclient.close()
Or you can use it as a context manager
>>>asyncwithApi()asclient:...boards=awaitclient.get_boards()... ...
Get all boards
>>>boards=awaitclient.get_boards()>>>boards(<Boardname='Фагготрия',id='fag'>, ... )
In addition we can getstatus
for each method. This is useful for debug purposes or if retries are needed
>>>status,boards=awaitclient.get_boards(return_status=True)>>>status200>>>boards(<Boardname='Фагготрия',id='fag'>, ... )
Get all threads from a board
>>>threads=awaitclient.get_board_threads(board="b")>>>threads(<Threadnum='180981319'>, ... )
Get top threads from a board sorted by method (views,score orposts_count)
>>>top_threads=awaitclient.get_top_board_threads(board="b",method="views",num=3)>>>top_threads(<Threadnum='180894312'>,<Threadnum='180946622'>,<Threadnum='180963318'>)
Get all thread's posts (thread
is an instance ofThread
)
>>>thread_posts=awaitclient.get_thread_posts(thread=thread)>>>thread_posts(<Postnum='180894312'>, ... )
Get all thread's posts by url
>>>thread_posts=awaitclient.get_thread_posts(thread="https://2ch.hk/test/res/30972.html")>>>thread_posts(<Postnum='30972'>, ... )
Get all media in all thread's posts (images, webm and so on)
>>>thread_media=awaitclient.get_thread_media(thread=thread)>>>thread_media(<Filename='15336559148500.jpg',path='/b/src/180979032/15336559148500.jpg',size='19'>, ... )
Get specific thread media
>>>images_and_videos=awaitclient.get_thread_media(thread,media_type=(Image,Video))>>>images_and_videos(<Imagename=...>,<Videoname=...>, ...)>>>just_images=awaitclient.get_thread_media(thread,media_type=Image)>>>just_images(<Imagename=...>, ...)
Download all thread media
>>>awaitclient.download_thread_media(files=thread_media,save_to="./downloads")
About
Fully asynchronous read-only API wrapper for 2ch.hk (dvach, Двач)