microlink logo

Microlink Recipe

Interact with canopy.co

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

const canopy = (url, opts) =>
  mql(url, {
    data: {
      products: {
        selectorAll: '.product-card',
        attr: {
          title: {
            type: 'title',
            selector: '.product-details-name',
            attr: 'text',
          },
          url: {
            type: 'url',
            selector: '.product-link-tracking',
            attr: 'href',
          },
          amazonUrl: {
            type: 'url',
            selector: '.card-buy-button',
            attr: 'href',
          },
          image: {
            type: 'img',
            selector: '.product-card-image img',
            attr: 'src',
          },
          brand: {
            type: 'title',
            selector: '.product-details-brand',
            attr: 'text',
          },
        },
      },
    },
    click: '.LoadMoreButton',
    ...opts,
  })

const result = await canopy('https://canopy.co/shop/everyday-carry')
console.log(result)