File manager - Edit - /home/cipherteam/htdocs/cipherteam.in/APPS/CronJobs/Kfintech/kfin_fetch_ipo_list.js
Back
process.env.PUPPETEER_CACHE_DIR = "/home/cipherteam/.cache/puppeteer"; const puppeteer = require("puppeteer"); const delay = (ms) => new Promise((res) => setTimeout(res, ms)); (async () => { const browser = await puppeteer.launch({ headless: true, args: ["--no-sandbox", "--disable-setuid-sandbox"], }); try { const page = await browser.newPage(); await page.setViewport({ width: 1200, height: 800 }); await page.goto("https://ipostatus.kfintech.com/", { waitUntil: "networkidle2", timeout: 60000, }); await delay(5000); // Open Select IPO dropdown const selectors = [ "[role='combobox']", ".mat-select-trigger", ".mat-mdc-select-trigger", "mat-select", ]; let opened = false; for (const sel of selectors) { const el = await page.$(sel); if (el) { try { await el.click(); opened = true; break; } catch {} } } if (!opened) { console.log(JSON.stringify({ ok: false, error: "Cannot open Select IPO" })); return; } await delay(1500); // Extract IPO name + data-value const options = await page.evaluate(() => { const list = []; const optionSelectors = [ "mat-option", ".mat-option", ".mat-mdc-option", "[role='option']", ]; optionSelectors.forEach((sel) => { document.querySelectorAll(sel).forEach((el) => { const name = (el.innerText || "").trim().replace(/\s+/g, " "); const value = el.getAttribute("data-value") || el.getAttribute("value") || el.getAttribute("ng-reflect-value") || ""; if (name && value) { list.push({ name, value, }); } }); }); // Remove duplicates by value const uniq = {}; list.forEach((i) => (uniq[i.value] = i)); return Object.values(uniq); }); console.log( JSON.stringify({ ok: true, count: options.length, options, }) ); } catch (e) { console.log(JSON.stringify({ ok: false, error: String(e) })); } finally { await browser.close(); } })();
| ver. 1.4 |
Github
|
.
| PHP 8.2.9 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings