I've been running the following code in order to download a csv
file from the website http://niftyindices.com/resources/holiday-calendar
:
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({headless: true});
const page = await browser.newPage();
await page.goto('http://niftyindices.com/resources/holiday-calendar');
await page._client.send('Page.setDownloadBehavior', {behavior: 'allow',
downloadPath: '/tmp'})
await page.click('#exportholidaycalender');
await page.waitFor(5000);
await browser.close();
})();
with headless: false
it works, it downloads the file into /Users/user/Downloads
. with headless: true
it does NOT work.
I'm running this on a macOS Sierra (MacBook Pro) using puppeteer version 1.1.1
which pulls Chromium version 66.0.3347.0
into .local-chromium/
directory and used npm init
and npm i --save puppeteer
to set it up.
Any idea whats wrong?
Thanks in advance for your time and help,
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…