-
A command line terminal, if you're not familiar with it you can read this post explaining the basics. For the best experience, we recommend you iTerm2 an alternative to the pre-install macOS terminal.
-
The JavaScript runtime Node.js. If you're a brew user you can simply
brew install node
, otherwise you can download it here. Moreover here's an article where you can find more information about how to install it and use it.
To be sure both of these tools are OK, open a terminal and run:
โถ node -v
v10.7.0
โถ npm -v
6.2.0
And check the version of node installed is upper than 8.
Create a new folder:
โถ mkdir ~/Desktop/puppeteer-setup-test && cd ~/Desktop/puppeteer-setup-test
And install Puppeteer node package:
โถ npm install puppeteer
Create a new script (new file) as an example and save it as example.js. This script will automatically navigate to a website and saving a screenshot of it:
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://spendesk.com');
await page.screenshot({ path: 'spendesk.png' });
await browser.close();
})();
Execute it:
โถ node example.js
And you will find a new spendesk.png file in your folder with the best website you've ever seen.
That's all for now! You are ready to start scraping all the web ๐