microlink logo

Microlink Recipe for Hacker News

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

const hackerNews = (opts) =>
  mql('https://news.ycombinator.com', {
    data: {
      posts: {
        selectorAll: '.athing',
        attr: {
          title: {
            type: 'title',
            selector: '.storylink',
            attr: 'text',
          },
          url: {
            type: 'url',
            selector: '.storylink',
            attr: 'href',
          },
        },
      },
    },
    ...opts,
  })

const result = await hackerNews('https://news.ycombinator.com')
console.log(result)