email worker
This commit is contained in:
parent
241b7a8712
commit
05fcdc0b12
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -61,7 +61,7 @@ export const puppeteerLoader = async (url: string, headless: boolean, location:
|
|||||||
url,
|
url,
|
||||||
{
|
{
|
||||||
launchOptions: {
|
launchOptions: {
|
||||||
headless: headless,
|
headless: false,
|
||||||
ignoreHTTPSErrors: true
|
ignoreHTTPSErrors: true
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -93,13 +93,11 @@ export const puppeteerLoader = async (url: string, headless: boolean, location:
|
|||||||
// Poll for cancellation
|
// Poll for cancellation
|
||||||
while (!isFinished) {
|
while (!isFinished) {
|
||||||
await new Promise(r => setTimeout(r, 1000));
|
await new Promise(r => setTimeout(r, 1000));
|
||||||
logger.info('Checking cancellation for ' + url);
|
|
||||||
if (await checkCancelled()) {
|
if (await checkCancelled()) {
|
||||||
const browser = await getBrowser();
|
const browser = await getBrowser();
|
||||||
if (browser) {
|
if (browser) {
|
||||||
const pid = browser.process()?.pid;
|
const pid = browser.process()?.pid;
|
||||||
logger.info(`Cancellation confirmed for process ${pid}`);
|
logger.info(`Cancellation confirmed for process ${pid}`);
|
||||||
// await browser.close(); // Do not close shared browser
|
|
||||||
}
|
}
|
||||||
|
|
||||||
reject(new Error('CancelledByUser'));
|
reject(new Error('CancelledByUser'));
|
||||||
@ -212,7 +210,6 @@ export const findEmailEach = async (location: LocalResult, opts: { headless?: bo
|
|||||||
|
|
||||||
page.status = 'SEARCHING_EMAIL'
|
page.status = 'SEARCHING_EMAIL'
|
||||||
try {
|
try {
|
||||||
logger.info(`Scraping email from ${page.url}`)
|
|
||||||
const pageEmails = await findEMail('find email', page.url, opts, location)
|
const pageEmails = await findEMail('find email', page.url, opts, location)
|
||||||
if (pageEmails && Array.isArray(pageEmails)) {
|
if (pageEmails && Array.isArray(pageEmails)) {
|
||||||
emails.push(...pageEmails)
|
emails.push(...pageEmails)
|
||||||
|
|||||||
@ -112,8 +112,6 @@ export const parseHtml = async (url: string, config: AxiosRequestConfig | null,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`[ParseHtml] Successfully fetched ${url}, content length: ${content.length}`);
|
|
||||||
|
|
||||||
const $ = cheerio.load(content)
|
const $ = cheerio.load(content)
|
||||||
const og: Og = {}
|
const og: Og = {}
|
||||||
const meta: Meta = {}
|
const meta: Meta = {}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user