Skip to content

Microlink × Hacker News

Interact with
ycombinator.com

hackerNews.js
import createClient from 'microlink.io'

const microlink = createClient()

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

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

console.log(result)