4chanapi.js 中文文档教程
install
通常。
npm install --save 4chanapi.js
usage
导出了两个函数,一个用于获取特定板上与关键字数组中的任何一个匹配的线程,另一个用于返回给定线程的媒体链接。 这是通过 promises 或 async/await 完成的。
example
let chan = require('4chanapi.js')
async function testIt() {
let threads = await chan.threadsWithTopics("v", ["rpg", "metal gear"])
console.log(threads)
let results = await chan.threadMediaLinks(threads[0].url)
console.log(results)
}
testIt()
在上面的示例中,threads
将是一个对象数组,如下所示:
[ { url: 'https://a.4cdn.org/v/thread/123.json',
semantic_url: 'do-people-actually-find-puzzle-maps-in-rpgs-fun' },
{ url: 'https://a.4cdn.org/v/thread/321.json',
semantic_url: 'best-story-in-gaming-with-xenogears' } ]
url
是该线程的 json api 端点的 url,由其他函数使用。 semantic_url
是 slugified 线程标题,适合用作文件夹名称。 results
的输出是一组简单的字符串值,表示线程中的图片/webms。
[ 'https://i.4cdn.org/v/123.png' ]
没有提供实际下载图像的功能,这取决于您。
install
The usual.
npm install --save 4chanapi.js
usage
There are two functions exported, one to grab the threads on a particular board that match any of an array of keywords, and one that returns the media links for a given thread. This is done via promises or async/await.
example
let chan = require('4chanapi.js')
async function testIt() {
let threads = await chan.threadsWithTopics("v", ["rpg", "metal gear"])
console.log(threads)
let results = await chan.threadMediaLinks(threads[0].url)
console.log(results)
}
testIt()
In the above example threads
would be an array of objects like this:
[ { url: 'https://a.4cdn.org/v/thread/123.json',
semantic_url: 'do-people-actually-find-puzzle-maps-in-rpgs-fun' },
{ url: 'https://a.4cdn.org/v/thread/321.json',
semantic_url: 'best-story-in-gaming-with-xenogears' } ]
The url
is the url of the json api endpoint for that thread, as used by the other function. The semantic_url
is the slugified thread title, suitable for use as a folder name. The output of results
is an array of simple string values representing the pictures/webms in the thread.
[ 'https://i.4cdn.org/v/123.png' ]
There's no function provided to actually download the images, that's up to you.
你可能也喜欢
- @00sukhjeet00/compilerjs 中文文档教程
- @0x/contracts-exchange-forwarder 中文文档教程
- @21epub/use-rxjs-subject 中文文档教程
- @a_fairlie/lotide 中文文档教程
- @abban-fahim/component-library 中文文档教程
- @abbit/bunyan-cloud-function 中文文档教程
- @abcfe/react-native-growingio 中文文档教程
- @abdulghani/reduxcontext 中文文档教程
- @abersager/apollo-composable 中文文档教程
- @abhisekp/inquirer-npm-name 中文文档教程