|
import {USER, PASSWORD} from './config.mjs';
|
|
|
|
import puppeteer from 'puppeteer';
|
|
|
|
const FORM = process.argv[2];
|
|
|
|
(async () => {
|
|
const browser = await puppeteer.launch();
|
|
const page = await browser.newPage();
|
|
await page.goto('https://forms.ncl.ac.uk');
|
|
await page.waitForSelector('#logincontainer');
|
|
await page.type('input[id="username"]', USER);
|
|
await page.type('input[id="password"]', PASSWORD);
|
|
await page.click('button[type="submit"]');
|
|
await page.waitForSelector('#seeyourforms');
|
|
const csv = await page.evaluate(async (FORM) => {
|
|
const response = await fetch(`https://forms.ncl.ac.uk/export_entries.php?type=csv&form_id=${FORM}`,
|
|
{
|
|
method: 'GET',
|
|
credentials: 'include'
|
|
}
|
|
);
|
|
const text = await response.text();
|
|
return text;
|
|
}, FORM);
|
|
console.log(csv);
|
|
|
|
await browser.close();
|
|
})();
|