kikobeats's notebooks

  • Microlink x og:image - /kikobeats/microlink-x-og-image
    Last edited 2 months ago
    const mql = require('@microlink/mql') const { data } = await mql('https://kikobeats.com', { data: { ogImage: { selector: [ 'meta[property="og:image:secure_url"]', 'meta[property="og:image:url"]', 'meta[property="og:image"]', ], attr: 'content', type: 'image', } } }) console.log( `The og:image is '${data.ogImage.url}' (${data.ogImage.size_pretty})` )
  • Microlink API x page-weight - /kikobeats/microlink-page-weight
    Last edited 6 months ago
    const mql = require('@microlink/mql') const bytes = require('bytes') Promise.resolve().then(async () => { const { data } = await mql('https://timer.blog/', { meta: false, data: { resources: { evaluate: "window.performance.getEntriesByType('resource').map(resource => ({ transferredSize: resource.transferSize, decodedBodySize: resource.decodedBodySize }))" } } }) const { resources } = data const [transferSize, resourcesSize] = resources .reduce( (acc, { transferredSize, decodedBodySize }) => { acc[0] += transferredSize acc[1] += decodedBodySize return acc }, [0, 0] ) .map(bytes) const resume = ` ⬩ ${resources.length} network requests ⬩ ${transferSize} transferred bytes ⬩ ${resourcesSize} resources bytes` console.log(resume) })
  • Microlink x Instagram - /kikobeats/microlink-x-instagram
    Last edited 3 years ago
    const mql = require('@microlink/mql') const avatar = async (url, opts) => { const { data } = await mql(url, { // force: true, apiKey: '', data: { avatar: { selector: 'meta[property="og:image"]', attr: 'content', type: 'image' } }, ...opts }) return data.avatar } const avatarUrl = await avatar('https://www.instagram.com/willsmith/') console.log(avatarUrl)
  • Microlink x hitpromo - /kikobeats/microlink-x-hitpromo
    Last edited 4 years ago
    const mql = require('@microlink/mql') const { response, data } = await mql('https://www.hitpromo.net/product/show/ZBOX-CUBE/small-cube-box', { data: { image: { selector: 'meta[name="og:image"]', attr: 'content' } } }) console.log(response.url) console.log(data)
  • Microlink x iHeartRADIO - /kikobeats/microlink-x-iheartradio
    Last edited 4 years ago
    const mql = require('@microlink/mql') const { data } = await mql('https://www.iheart.com/podcast/105-stuff-you-should-know-26940277/episode/sysk-selects-how-lobbying-works-68924034/', { prerender: false, data: { desc: { selector: '#initialState' } } }) console.log({desc: data.desc})
  • MQL x GitHub - /kikobeats/mql-x-github
    Last edited 4 years ago
    const mql = require('@microlink/mql') const github = (username) => mql(`https://github.com/${username}`, { data: { stats: { selector: '.user-profile-nav nav', attr: { repositories: { selector: 'a:nth-child(2) > span', type: 'number' }, followers: { selector: 'a:nth-child(4) > span', type: 'number' }, followings: { selector: 'a:nth-child(5) > span', type: 'number' } } } } }) const username = 'kikobeats' const { response, data } = await github(username) console.log(`GitHub stats for @${username}:`, data.stats)
  • MQL x Product Hunt - /kikobeats/mql-x-product-hunt
    Last edited 4 years ago
    const mql = require('@microlink/mql') const productHunt = (id) => mql(`https://www.producthunt.com/posts/${id}`, { data: { name: { selector: 'h1 a', attr: 'text', type: 'string', }, upvotes: { selector: '.bigButtonCount_10448', attr: 'text', type: 'string', }, }, }) const productSlug = 'microlink-2-0' const { data, response } = await productHunt(productSlug) console.log(JSON.stringify(response.url)) console.log(`'${data.name}' has ${data.upvotes} upvotes`)
  • MQL x Hacker News - /kikobeats/mql-x-hacker-news
    Last edited 4 years ago
    const mql = require('@microlink/mql') const hackerNews = () => mql('https://news.ycombinator.com/', { data: { posts: { selectorAll: '.athing', attr: { title: { type: 'title', selector: '.storylink', attr: 'text', }, url: { type: 'url', selector: '.storylink', attr: 'href', }, }, }, }, }) const { data, response } = await hackerNews() console.log('latest hacker news posts:', data.posts) console.log(JSON.stringify(response.url))
  • MQL x Twitter - /kikobeats/mql-x-twitter
    Last edited 4 years ago
    const mql = require('@microlink/mql') const twitter = (username) => mql(`https://twitter.com/${username}`, { 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', }, }, }, }, }) const username = 'microlinkhq' const { response, data } = await twitter(username) console.log(`stats for @${username}:`, data.stats)
  • MQL x Meetup - /kikobeats/mql-x-meetup
    Last edited 4 years ago
    const mql = require('@microlink/mql') const meetup = url => mql(url, { adblock: false, data: { title: [ { selector: 'title', attr: 'text', type: 'title' }, { selector: 'meta[property="og:title"]:not([content=""])', attr: 'content', type: 'title' }, { selector: 'meta[name="twitter:title"]:not([content=""])', attr: 'content', type: 'title' } ], description: [ { selector: 'meta[name="description"]:not([content=""])', attr: 'content', type: 'description' }, { selector: 'meta[property="og:description"]:not([content=""])', attr: 'content', type: 'description' }, { selector: 'meta[name="twitter:description"]:not([content=""])', attr: 'content', type: 'description' }, { selector: '.event-description', attr: 'text', type: 'description' } ], json: { selector: 'script[type="application/ld+json"]', type: 'object' } } }) const { data } = await meetup('https://www.meetup.com/Marin-Mountain-Biking/events/268362491/') console.log(data)