This commit is contained in:
Gergő Móricz 2025-06-04 01:13:11 +02:00
parent 5747af9557
commit db75e560a6
2 changed files with 5 additions and 2 deletions

View File

@ -70,8 +70,6 @@ describe("Scrape tests", () => {
formats: ["rawHtml"],
});
console.log(response.rawHtml, response.metadata.contentType);
const obj = JSON.parse(response.rawHtml!);
expect(obj.id).toBe(1);
}, 30000);

View File

@ -3,6 +3,7 @@ import { EngineScrapeResult } from "..";
import { Meta } from "../..";
import { TimeoutError } from "../../error";
import { robustFetch } from "../../lib/fetch";
import { getInnerJSON } from "../../../../lib/html-transformer";
export async function scrapeURLWithPlaywright(
meta: Meta,
@ -42,6 +43,10 @@ export async function scrapeURLWithPlaywright(
})(),
]);
if (response.contentType?.includes("application/json")) {
response.content = await getInnerJSON(response.content);
}
return {
url: meta.url, // TODO: impove redirect following
html: response.content,