microlink logo

Microlink Recipe for Twitter

twitter.js
const mql = require('@microlink/mql')

const twitter = (url, opts) =>
  mql(url, {
    data: {
      stats: {
        selector: '.ProfileNav-list',
        attr: {
          tweets: {
            selector: '.ProfileNav-item--tweets .ProfileNav-value',
            attr: 'data-count',
          },
          followings: {
            selector: '.ProfileNav-item--following .ProfileNav-value',
            attr: 'data-count',
          },
          followers: {
            selector: '.ProfileNav-item--followers .ProfileNav-value',
            attr: 'data-count',
          },
        },
      },
    },
    ...opts,
  })

const result = await twitter('https://twitter.com/microlinkhq')
console.log(result)