Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

216
Views
¿Cómo importar varios paquetes de NodeJS juntos?
const metascraper = require('metascraper')([ require('metascraper-author')(), require('metascraper-date')(), require('metascraper-description')(), require('metascraper-image')(), require('metascraper-logo')(), require('metascraper-clearbit')(), require('metascraper-publisher')(), require('metascraper-title')(), require('metascraper-url')() ])

Tengo el siguiente código, pero const no funciona, así que tengo que usar import

 import metascraper from 'metascraper'; import title from 'metascraper-title'; import image from 'metascraper-image'; ...

Esto no funciona como se esperaba y devuelve indefinido: ¿cómo puedo importar todas esas bibliotecas debajo metascraper usando import . Importarlos manualmente con su propio nombre no funciona.

 (async () => { try { // Use the got library to fetch the website content. const targetUrl = 'http://www.bloomberg.com/news/articles/2016-05-24/as-zenefits-stumbles-gusto-goes-head-on-by-selling-insurance'; const { body: html, url } = await got(targetUrl); // Extract the metadata from the website content. const metascraper = await metascraper(title(),{ html, url }); // Return the metadata as JSON console.log(JSON.stringify(metascraper)); } catch (err) { console.log(err); } })()
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Lo siguiente debería funcionar:

 import got from "got"; import _metascraper from "metascraper"; import title from "metascraper-title"; import image from "metascraper-image"; import author from "metascraper-author"; // ... const metascraper = _metascraper([title(), image(), author()]); try { // Use the got library to fetch the website content. const targetUrl = "https://wesbos.com/scoped-github-access-token/"; const { body: html, url } = await got(targetUrl); // Extract the metadata from the website content. const metadata = await metascraper({ html, url }); // Return the metadata as JSON console.log(metadata); } catch (err) { console.log(err); }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!