I got set of urls from txt file [which I am having in my local] which I got as array inputs with below code
fs.readFile('urls.txt', function(err, data) {
if(err) throw err;
var testurls = data.toString().split("\n");
});
Sample output when I do console.log(testurls) [ 'https://sample1.com' 'https://sample2.com' ]
How to pass the values to below function as parameter/argument to run scan on each url one after other as I am trying to some performance test using light house?
async function nav_to_site() {
const home_url = testurls;
const browser = await puppeteer.launch({
headless: true,
defaultViewport: null,
executablePath: '/usr/local/bin/chromium',
args: ['--headless', '--no-sandbox', '--remote-debugging-port=9222', '--disable-gpu'],
});
(async () => {
let browser = null;
let page = null;
try {
browser = await nav_to_site();
console.log('Running lighthouse...');
page = (await browser.pages())[0];
const report = await lighthouse(page.url(), {
port: 9222,
output: 'json',
logLevel: 'info',
disableDeviceEmulation: true,
budgetPath: 'budget.json',
chromeFlags: ['--disable-gpu', '--no-sandbox', '--disable-storage-reset']
}, config);
const json = reportGenerator.generateReport(report.lhr, 'json');
const html = reportGenerator.generateReport(report.lhr, 'html');
}