4CHAN 满?
www.4chan.org 非官方只读 API。
npm install 4chan-full
自定义请求处理程序 ( new FourChanFull(yourHandler)
);
获取线程 ( .thread(boardCode, threadId)
)
监视线程更新 ( .threadWatcher(boardCode, threadId, [options])
);
获取主板 ( .board(boardCode, page)
)
获取存档 ( .archive(boardCode)
)
获取热门话题 ( .popular(safetyType)
)
获取统计信息 ( .stats()
)
董事会列表 ( .boards
)
那个小脚本列出了线程的所有文件..
const { fchf } = require ( "4chan-full" ) ;
( async ( ) => {
const thread = await fchf . thread ( "wg" , "7694540" ) ;
// thread.file -> Thread owner (OP) file.
// thread.replies[?].file -> reply file.
const files = [ thread . file , ... thread . replies . map ( ( i ) => i ?. file ) ] . filter (
( i ) => i != null
) ;
console . log ( files ) ;
} ) ( ) ;
那个小脚本监视线程的新回复。
const { fchf } = require ( "4chan-full" ) ;
( async ( ) => {
let watcher = fchf . threadWatcher ( "vg" , "337012489" ) ;
// Events: updated, nowUpdated, checked, error, #start, #stop
watcher . on ( "updated" , ( oldThread , newThread ) => {
console . log ( { oldThread , newThread } ) ;
} ) ;
watcher . on ( "notUpdated" , ( ) => {
console . log ( "there is no new replies.." ) ;
} ) ;
watcher . on ( "checked" , ( oldThread , newThread ) => {
console . log ( "checked new checkInterval:" , watcher . checkInterval ) ;
} ) ;
watcher . start ( ) ;
} ) ( ) ;