用于4chan api和其他imageboard的python包装器

py-chan-api的Python项目详细描述


py chan api

目标:

  • unify:将其他图像板转换为json格式的4chan api
  • wrapper:将json解析为编程语言特定的数据结构
  • extra:下载json+media的能力

为什么?

我有很多线程存档在一个纯文本的链接列表中,用于教育目的。随着存档网站的出现,我意识到它不会一直在这里,我需要把它保存在本地。后来,它提醒我,不仅这些需要存档,而且在互联网上的其他一切,我的价值。

支持:

FeatureSource
✔️ Single thread^{}
✔️ Thread index^{} (threads @ pg #)
✔️ Board list^{}
✔️ Board catalog^{}
✔️ Thread list^{}
✔️ Archived threads^{}
⚠️ HTTPSOn by default in ^{}
⚠️ Rate limiting^{} requests allowed in ^{} seconds
⚠️ ^{}^{}
⚠️ In-place thread updating^{}
Extra ImageboardsCompatibility
✔️ FFuuka^{}, ^{}
❔ warosu
❔ yuki.la

安装

pipinstallpy-chan-api# NOTE: Only Python 3.7+# Or with virtualenvpipinstallvirtualenv# Install virtualenv if you havent alreadyvirtualenvvenv# Create a virtualenvsourcevenv/bin/activate# Activate itpipinstall-rrequirements.txt# Install required modulespipinstallpy-chan-api# Install py-chan-api

使用量

importpychan# pychan infers what type of object you're giving it. See the above table.# Whether its a string pointing to a file/dict/dict in string format.thread=pychan.FourChan("thread.json")post=thread.posts[0]threadIndex=pychan.FourChan("thread_index.json")board=pychan.FourChan("boards.json")thread=pychan.FourChan("thread.json")threadList=pychan.FourChan("thread_list.json")archivedThread=pychan.FourChan("archived_threads.json")print(thread.posts[0].com)# Get the first post and its commentprint(post)# If you're unsure of what fields to call# just print the object itself to see a list of key/valuesprint(thread.posts[0])print(threadIndex.threads[0].posts[1])print(board.trollflags.AC)print(board.boards[0].title)print(catalog.page[0].threads[0])print(threadList.page[0].threads[0])print(archivedThread[-1])# To get individual key value/pairsjdb=thread.posts[0].json# Convert the Post object to a dictionaryfork,vinjdb.items():# Iterate through the key/value pairsprint(k,v)

转换

importpychanfuukaThread=pychan.Fuuka("desu_thread.json")# Specify the imageboard implementation# Parallelism (multiprocessing) is turned on automatically if you supply more# than one key/value pairs in a dictionary.# You can override this behaviour by specifying the parallel field# By using a dictionary, you can also output it to a file.fthread1=pychan.Fuuka({"desu_thread.json":"out1.json"},parallel=True)# Which then you could read it as a normal 4chan jsonfthread=pychan.FourChan("out1.json")# We can also just use the outputed value from beforeprint(fthread1.posts[1])# Note: fthread1 is the same as fthread and fuukaThread

支持

欢迎拉取请求。 请随意ping shiimizu@thisMatrix服务器。

轮询(archiving

  • 存档功能超出了本项目的范围。
  • 请参见:箭头右:

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

推荐PyPI第三方库


热门话题
java Maven发布插件在创建标记时失败   opencv使用java控制网络摄像头LED灯   java在使用JTA时不能使用EntityTransaction。使用非JTA   java映射大小与实际条目不同   javaspringboot。执行saveAndFlush并将实体结果修改为未保存的trancient异常   java在Selenium 3.0.0中运行Selenium IDE?   用于捕获键/值的java正则表达式   java Ivy的transitive=“false”在从Nexus下载时被忽略   JavaSpring引导忽略应用程序中的数据源url。yml   可以使用正则表达式拆分Java字符串,但正则表达式匹配返回false   log4j2中的javakafka追加器。xml不起作用   循环java测试分数统计   JFrame中边框的java返回类型   java在LibGDX中如何防止相机延迟?