mirror of
https://git.mirrors.martin98.com/https://github.com/mendableai/firecrawl
synced 2025-08-14 23:55:54 +08:00
feat(scrapeURL/pdf/mu): add timeout and created_at (#1570)
This commit is contained in:
parent
fab4f00536
commit
192d056bef
@ -27,6 +27,8 @@ async function scrapePDFWithRunPodMU(
|
|||||||
tempFilePath,
|
tempFilePath,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const preCacheCheckStartTime = Date.now();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const cachedResult = await getPdfResultFromCache(base64Content);
|
const cachedResult = await getPdfResultFromCache(base64Content);
|
||||||
|
|
||||||
@ -54,6 +56,8 @@ async function scrapePDFWithRunPodMU(
|
|||||||
input: {
|
input: {
|
||||||
file_content: base64Content,
|
file_content: base64Content,
|
||||||
filename: path.basename(tempFilePath) + ".pdf",
|
filename: path.basename(tempFilePath) + ".pdf",
|
||||||
|
timeout: timeToRun ? timeToRun - (Date.now() - preCacheCheckStartTime) : undefined,
|
||||||
|
created_at: Date.now(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
logger: meta.logger.child({
|
logger: meta.logger.child({
|
||||||
@ -103,6 +107,8 @@ export async function scrapePDF(
|
|||||||
meta: Meta,
|
meta: Meta,
|
||||||
timeToRun: number | undefined,
|
timeToRun: number | undefined,
|
||||||
): Promise<EngineScrapeResult> {
|
): Promise<EngineScrapeResult> {
|
||||||
|
const startTime = Date.now();
|
||||||
|
|
||||||
if (!meta.options.parsePDF) {
|
if (!meta.options.parsePDF) {
|
||||||
if (meta.pdfPrefetch !== undefined && meta.pdfPrefetch !== null) {
|
if (meta.pdfPrefetch !== undefined && meta.pdfPrefetch !== null) {
|
||||||
const content = (await readFile(meta.pdfPrefetch.filePath)).toString("base64");
|
const content = (await readFile(meta.pdfPrefetch.filePath)).toString("base64");
|
||||||
@ -167,7 +173,7 @@ export async function scrapePDF(
|
|||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
tempFilePath,
|
tempFilePath,
|
||||||
timeToRun,
|
timeToRun ? (timeToRun - (Date.now() - startTime)) : undefined,
|
||||||
base64Content,
|
base64Content,
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user