Support chrome-cdp and restructure sitemap fire-engine support.

This commit is contained in:
Thomas Kosmas
2024-07-15 18:40:43 +03:00
parent 8efd444ba2
commit 5c65ec58e5
3 changed files with 24 additions and 2 deletions
@@ -31,6 +31,7 @@ export async function scrapWithFireEngine({
fireEngineOptions?: FireEngineOptions;
headers?: Record<string, string>;
options?: any;
engine?: 'playwright' | 'chrome-cdp' | 'tlsclient';
}): Promise<FireEngineResponse> {
const logParams = {
url,
@@ -49,7 +50,14 @@ export async function scrapWithFireEngine({
const screenshotParam = reqParams["params"]?.screenshot ?? screenshot;
const fireEngineOptionsParam : FireEngineOptions = reqParams["params"]?.fireEngineOptions ?? fireEngineOptions;
let endpoint = fireEngineOptionsParam.method === "get" ? "/request" : "/scrape";
let endpoint = "/scrape";
if(options?.endpoint === "request") {
endpoint = "/request";
}
let engine = fireEngineOptions?.engine ?? options?.engine ?? "playwright"; // do we want fireEngineOptions as first choice?
console.log(
`[Fire-Engine] Scraping ${url} with wait: ${waitParam} and screenshot: ${screenshotParam} and method: ${fireEngineOptionsParam?.method ?? "null"}`
@@ -65,6 +73,7 @@ export async function scrapWithFireEngine({
screenshot: screenshotParam,
headers: headers,
pageOptions: pageOptions,
engine: engine,
...fireEngineOptionsParam,
},
{