LoginSignup
2
2

More than 5 years have passed since last update.

Pocketされた数を取得(node.js)

Posted at

PocketボタンのHTMLを取得してパースするしかないらしい。面倒だな。。

const jsdom = require('jsdom');

const TARGET = 'http://qiita.com/KeitaMoromizato/items/fe37ed75816554a6be54';

jsdom.env(
  `https://widgets.getpocket.com/v1/button?label=pocket&count=vertical&align=left&v=1&url=${TARGET}`,
  [], (error, window) => {
    if (error) {
      console.error(error);
      process.exit(-1);
    }

    const countEl = window.document.querySelector('#cnt');
    console.log(+countEl.innerHTML);
  }
);
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2