mirror of
https://git.mirrors.martin98.com/https://github.com/mendableai/firecrawl
synced 2025-08-14 10:15:54 +08:00
fix json
This commit is contained in:
parent
5747af9557
commit
db75e560a6
@ -70,8 +70,6 @@ describe("Scrape tests", () => {
|
|||||||
formats: ["rawHtml"],
|
formats: ["rawHtml"],
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(response.rawHtml, response.metadata.contentType);
|
|
||||||
|
|
||||||
const obj = JSON.parse(response.rawHtml!);
|
const obj = JSON.parse(response.rawHtml!);
|
||||||
expect(obj.id).toBe(1);
|
expect(obj.id).toBe(1);
|
||||||
}, 30000);
|
}, 30000);
|
||||||
|
@ -3,6 +3,7 @@ import { EngineScrapeResult } from "..";
|
|||||||
import { Meta } from "../..";
|
import { Meta } from "../..";
|
||||||
import { TimeoutError } from "../../error";
|
import { TimeoutError } from "../../error";
|
||||||
import { robustFetch } from "../../lib/fetch";
|
import { robustFetch } from "../../lib/fetch";
|
||||||
|
import { getInnerJSON } from "../../../../lib/html-transformer";
|
||||||
|
|
||||||
export async function scrapeURLWithPlaywright(
|
export async function scrapeURLWithPlaywright(
|
||||||
meta: Meta,
|
meta: Meta,
|
||||||
@ -42,6 +43,10 @@ export async function scrapeURLWithPlaywright(
|
|||||||
})(),
|
})(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
if (response.contentType?.includes("application/json")) {
|
||||||
|
response.content = await getInnerJSON(response.content);
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
url: meta.url, // TODO: impove redirect following
|
url: meta.url, // TODO: impove redirect following
|
||||||
html: response.content,
|
html: response.content,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user