python 4chan api包装器。改进版的Edgeworth的原始PY-4Chan包装。

BASC-py4chan的Python项目详细描述


Anonoma图书馆的4chan API的完整python包装。 使用请求,如果在更新线程时修改了自头,则会尊重。 缓存线程对象。有趣的东西。

如果你想与4chan接口或从4chan上刮下,绝对必须, 使用python脚本。

Hosted Documentation

Github Repository

您可以使用以下命令安装此库straight from PyPi

pip install basc-py4chan

获取帮助

如果您需要帮助,或者您在使用这个库时遇到一些问题,我们的主要irc频道 是#bibanon on irc.rizon.net。简单的头部 在那里和丹或安东尼松谈谈。否则,您可以在我们的Github Issue Tracker上提出问题,我们会尽快答复 我们可以!


最初由Edgeworth编写,库 已被Bibliotheca Anonoma采用和扩展。

注意:如果您是一个仍然使用Edgeworth的py-4chan的开发人员,并且不使用 要更改函数名,bibliotheca anonoma维护一个up-to-date, API-compatible version of py-4chan here.

用法

importbasc_py4chanb=basc_py4chan.Board('b')thread=b.get_thread(423491034)print(thread)forfileinthread.files():print(file)# In a while...print("I fetched",thread.update(),"new replies.")

文档位于here

扩展此库

有很多其他imageboard api采用了与4chan api类似的结构(例如8chan/vichan或420chan)。Foolfuuka也有一个API,虽然它早于它们,但它可以根据需要定制。

因此,您可以继承并重写basc-py4chan来支持它们,而不是从头开始编写一个全新的类。这也将允许basc架构器可能使其工作。方法如下:

importbasc_py4chanclassURL(basc_py4chan.URL):# see BASC-py4chan's `url.py` for an example of how to set up# the URLs.def__init__(self,https=False):# Your API URL SubdomainsDOMAIN={}# Your API URL TemplatesTEMPLATE={}# Your API ListingsLISTING={}# combine all dictionaries into self.URL dictionaryself.URL=TEMPLATEself.URL.update({'domain':DOMAIN})self.URL.update({'listing':LISTING})classBoard(basc_py4chan.Board):# add your own overrides here, or leave it alonepassclassThread(basc_py4chan.Threads):# add your own overrides here, or leave it alonepassclassPost(basc_py4chan.Post):# add your own overrides here, or leave it alonepass# note that all classes must be in one file (we recommend#   py?chan/__init__.py ), due to how python modules work

从这里开始,只需根据需要重写类board、thread或post中的任何方法。

注意,如果您的imageboard的api不支持4chanapi中的某个特性,you should have the function raise an AttributeError.

许可证

           DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
                   Version 2, December 2004

Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>

Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.

           DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
  TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

 0. You just DO WHAT THE FUCK YOU WANT TO.

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java LineNumberReader。如果查询行为不正确,则返回readLine()   java包含了一个使用AndroidX的工具栏,这让我的应用程序崩溃了   JVM设置通过“java jar”运行应用程序的最佳实践   java如何获取ImageButton宽度   java Oracle SQLLDR实用程序无响应   列出Java获取对象的arrayList中最常见的元素   java使用带有FlowLayout的getContentpane对布局应用更改,但不起作用为什么?   在java中,我可以在画布上绘制画布吗?   编译游戏代码时发生java异常错误   从firestore获取java Webview失败   java将TableLayout中单元格的内容向右对齐   java无法在发布模式下启动活动(使用proguard安卓optimize配置)   java允许在线程期间进行GUI更新。睡觉   java如何对以变量为列表的列表进行排序   API URL上的java Google云端点异常