Expanded puppeteer options. Fixed Mike Adriano scraper. Fixed convert utility.
This commit is contained in:
@@ -79,7 +79,7 @@ function convertApi(input, fromOrTo, to) {
|
||||
|
||||
const inputNumber = Number(typeof input === 'string' ? input.match(/\d+(\.\d+)?/)?.[0] : input);
|
||||
|
||||
return Math.round(convert(inputNumber).from(fromOrTo).to(to)) || null;
|
||||
return Math.round(convert(inputNumber, fromOrTo).to(to)) || null;
|
||||
} catch (error) {
|
||||
logger.error(error);
|
||||
return null;
|
||||
|
||||
@@ -162,7 +162,7 @@ async function getBrowserSession(identifier, options = {}) {
|
||||
return limiters.bypass.schedule(async () => {
|
||||
if (!browser) {
|
||||
browser = await puppeteer.launch({
|
||||
headless: typeof options.headless === 'undefined' ? 'new' : options.headless,
|
||||
headless: typeof options.bypass?.headless === 'undefined' ? 'new' : options.bypass.headless,
|
||||
// headless: false,
|
||||
});
|
||||
|
||||
@@ -177,10 +177,19 @@ async function getBrowserSession(identifier, options = {}) {
|
||||
});
|
||||
}
|
||||
|
||||
async function bypassBrowserRequest(url, _options) {
|
||||
const { tab } = await getBrowserSession(new URL(url).hostname);
|
||||
async function bypassBrowserRequest(url, options) {
|
||||
const { tab } = await getBrowserSession(new URL(url).hostname, options);
|
||||
|
||||
const res = await tab.goto(url);
|
||||
|
||||
if (options.bypass?.delay) {
|
||||
await Promise.delay(options.bypass.delay);
|
||||
}
|
||||
|
||||
if (typeof options.bypass?.evaluate === 'function') {
|
||||
await tab.evaluate(options.bypass.evaluate, options.bypass);
|
||||
}
|
||||
|
||||
const rawBody = await tab.content();
|
||||
|
||||
const headers = res.headers();
|
||||
|
||||
Reference in New Issue
Block a user