如何 运行 一个 javascript github 存储库?
How to run a javascript github repository?
我找到了一个我想使用的 repo,它不包含太多说明,并且全部写在 javascript 中。我已经安装了基本要求,但我不知道如何进行。
这是添加额外功能的主要代码库 https://github.com/website-scraper/website-scraper-puppeteer and it uses the plugin https://github.com/puppeteer/puppeteer。
如何运行代码? README里没说清楚。
阅读 puppeteer 的说明。它解释说它是一个节点模块。
所以你需要从命令行安装node.js。
然后使用node的npm安装puppeteer。
然后添加插件。
最后,运行 木偶师
请先熟悉"what is a node.js application"。
https://www.tutorialspoint.com/nodejs/nodejs_introduction.htm
要使用 website-scraper-puppeteer 节点模块下载网站,您需要:
- 安装nodejs(版本>=8)
- 从 npm
安装模块 website-scraper
(核心模块),website-scraper-puppeteer
(核心模块的插件)
npm install website-scraper website-scraper-puppeteer
- 使用一些代码为您的 nodejs 应用程序(例如,
index.js
)创建文件
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); });
- 运行 你从命令行应用程序
node index.js
我找到了一个我想使用的 repo,它不包含太多说明,并且全部写在 javascript 中。我已经安装了基本要求,但我不知道如何进行。
这是添加额外功能的主要代码库 https://github.com/website-scraper/website-scraper-puppeteer and it uses the plugin https://github.com/puppeteer/puppeteer。
如何运行代码? README里没说清楚。
阅读 puppeteer 的说明。它解释说它是一个节点模块。
所以你需要从命令行安装node.js。
然后使用node的npm安装puppeteer。
然后添加插件。
最后,运行 木偶师
请先熟悉"what is a node.js application"。
https://www.tutorialspoint.com/nodejs/nodejs_introduction.htm
要使用 website-scraper-puppeteer 节点模块下载网站,您需要:
- 安装nodejs(版本>=8)
- 从 npm 安装模块
website-scraper
(核心模块),website-scraper-puppeteer
(核心模块的插件)
npm install website-scraper website-scraper-puppeteer
- 使用一些代码为您的 nodejs 应用程序(例如,
index.js
)创建文件
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); });
- 运行 你从命令行应用程序
node index.js