#!/usr/bin/env node import fetch from 'node-fetch'; import cheerio from 'cheerio'; function parseHtml(url, callback) { fetch(url) .then(response => response.text()) .then(html => cheerio.load(html)) .then(callback) .catch(console.error) ; } // Main if (process.argv.length !== 3) { console.log('Usage: npm run start http://example.com'); process.exit(); } parseHtml(process.argv[2], $ => { const srcList = []; $('img').each((i, element) => { srcList.push(img.src); }); console.dir(srcList); });