Skip to content

a26364177/ptt-client

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

76 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ptt-client

ptt-client is an unofficial client to fetch data from PTT (ptt.cc), the famous BBS in Taiwan, over WebSocket. This module works in browser and Node.js.

PTT supports connection with WebSocket by official.

Installation

npm install ptt-client

Example

import PTT from 'ptt-client';

// if you are using this module in node.js, 'ws' is required as WebSocket polyfill.
// you don't need this in modern browsers
global.WebSocket = require('ws');

(async function() {
  const ptt = new PTT();

  if (!await ptt.login('guest', 'guest'))
    return;

  // get last 20 articles from specific board
  let articles = await ptt.getArticles('C_Chat');

  // get the content of specific article
  let article = await ptt.getArticle('C_Chat', articles[articles.length-1].sn);

  // get your favorite list
  let favorites = await ptt.getFavorite();
})();

Development

npm run test
npm run build

About

A Node client for fetching data from ptt.cc

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%