Installation
MQL is available as
npm package
:npm install @microlink/mql --save
The package is fully typed and it has been designed for being consumed in different environments and ways.
Any Node.js above v16.14 is supported. We recommend to run using the active TLS. Check
Node.js releases
to know more.Just require
@microlink/mql
dependency from your code:const mql = require('@microlink/mql') const { data } = await mql('https://kikobeats.com', { data: { avatar: { selector: '#avatar', type: 'image', attr: 'src' } } }) console.log( `The avatar URL is '${data.avatar.url}' (${data.avatar.size_pretty})` )
The same build is available for CommonJS and ESM.
If you are using
CloudFlare Workers
, Vercel Edge Functions
, Deno
, or any other provider that supports WinterCG
, there is an special build takes advantage of Web Standard APIs.Just import
@microlink/mql/lightweight
from your code:import mql from '@microlink/mql/lightweight' const { data } = await mql('https://kikobeats.com', { data: { avatar: { selector: '#avatar', type: 'image', attr: 'src' } } }) console.log( `The avatar URL is '${data.avatar.url}' (${data.avatar.size_pretty})` )
The same build is available for CommonJS and ESM.
Last but not least, MQL can be loaded from any browser directly from HTML markup:
<script type="module"> import mql from 'https://esm.sh/@microlink/mql' const { data } = await mql('https://kikobeats.com', { data: { avatar: { selector: '#avatar', type: 'image', attr: 'src', } } }) console.log(`The avatar URL is '${data.avatar.url}' (${data.avatar.size_pretty})`) </script>