简体   繁体   中英

How to run a javascript github repository?

I found a repo I would like to use that does not include much instruction and is written in all javascript. I've installed the basic requirements, but I don't know how to proceed.
This is the main repo https://github.com/website-scraper/website-scraper-puppeteer and it uses the plugin https://github.com/puppeteer/puppeteer to add extra functionality.

How do I run the code? It is unclear in the README.

Read the instructions for puppeteer. It explains it's a node module.

So you need to install node.js from the command line.

Then using node's npm to install puppeteer.

Then add the plugin.

And finally, run puppeteer

Please acquaint yourself with "what is a node.js application" first.

https://www.tutorialspoint.com/nodejs/nodejs_introduction.htm

To download website using website-scraper-puppeteer node module you need:

  • install nodejs (version >= 8)
  • install modules website-scraper (core module), website-scraper-puppeteer (plugin for core module) from npm
npm install website-scraper website-scraper-puppeteer
  • create file for your nodejs application (for example, index.js ) with some code
const scrape = require('website-scraper');
const PuppeteerPlugin = require('website-scraper-puppeteer');

const options = {
    urls: ['https://example.com'],
    directory: '/path/to/save',
    plugins: [ 
      new PuppeteerPlugin()
    ]
};

scrape(options).then((result) => { console.log(result); });
  • run you app from command line
node index.js

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM