1const Apify = require('apify');
2const request = require('request-promise');
3
4const metascraper = require('metascraper')([
5 require('metascraper-author')(),
6 require('metascraper-date')(),
7 require('metascraper-description')(),
8 require('metascraper-image')(),
9 require('metascraper-video')(),
10 require('metascraper-youtube')(),
11 require('metascraper-logo')(),
12 require('metascraper-clearbit')(),
13 require('metascraper-publisher')(),
14 require('metascraper-title')(),
15 require('metascraper-url')()
16])
17
18
19Apify.main(async () => {
20
21 const input = await Apify.getInput();
22
23 if (!input || !input.url) throw new Error('Invalid input, must be a JSON object with the "url" field!');
24
25 const html = await request(input.url);
26 const metadata = await metascraper({ html: html, url: input.url })
27
28 console.dir(metadata)
29
30 await Apify.setValue('OUTPUT', JSON.stringify(metadata));
31});