Skip to content

Instantly share code, notes, and snippets.

View nsourov's full-sized avatar

Naimur Rahman nsourov

View GitHub Profile
@nsourov
nsourov / index.js
Created June 27, 2020 06:47
Puppeteer with p-queue
const puppeteer = require('puppeteer');
const PQueue = require('p-queue');
const queue = new PQueue({ concurrency: 2 });
const singleRunner = async (url) => {
const browser = await puppeteer.launch({ headless: false, executablePath: process.env.CHROME_PATH, });
const page = await browser.newPage();
await page.goto(url);
const title = await page.title();
var xlstojson = require("xls-to-json-lc");
var xlsxtojson = require("xlsx-to-json-lc");
function excelToJson(file) {
const ext = file.split(".").slice(-1)[0];
if (ext === "xlsx") {
xlsxtojson(
{
input: file,
output: `${__dirname}/output.json`
app.use((req, res, next) => {
res.header("Access-Control-Allow-Origin", "*"); // "*" for public access and www.example.com for specific uses
res.header(
"Access-Control-Allow-Headers",
"Origin, X-Requested-With, Content-Type, Accept, Authorization"
);
if (req.method === 'OPTIONS') {
res.header('Access-Control-Allow-Methods', 'PUT, POST, PATCH, DELETE, GET');
return res.status(200).json({});
}