pull/643/head^2
Travis Fischer 2024-06-04 22:58:32 -05:00
rodzic bf6ee7c9b2
commit 1c10060651
2 zmienionych plików z 38 dodań i 5 usunięć

Wyświetl plik

@ -58,8 +58,9 @@ async function main() {
const firecrawl = new FirecrawlClient()
const res = await firecrawl.scrapeUrl({
// url: 'https://www.bbc.com/news/articles/cp4475gwny1o'
url: 'https://www.firecrawl.dev'
url: 'https://www.bbc.com/news/articles/cp4475gwny1o'
// url: 'https://www.theguardian.com/technology/article/2024/jun/04/openai-google-ai-risks-letter'
// url: 'https://www.firecrawl.dev'
})
console.log(JSON.stringify(res, null, 2))

Wyświetl plik

@ -25,10 +25,33 @@ export namespace firecrawl {
*/
export interface ScrapeResponse {
success: boolean
data?: any
data?: Data
error?: string
}
export interface Data {
content?: string
markdown?: string
html?: string
metadata: Metadata
}
export interface Metadata {
title: string
description: string
keywords?: string
robots?: string
ogTitle?: string
ogDescription?: string
ogUrl?: string
ogImage?: string
ogLocaleAlternate?: any[]
ogSiteName?: string
sourceURL?: string
modifiedTime?: string
publishedTime?: string
}
/**
* Response interface for searching operations.
*/
@ -132,9 +155,18 @@ export class FirecrawlClient extends AIFunctionsProvider {
}
}
return this.ky
.post('v0/scrapeUrl', { json })
const res = await this.ky
.post('v0/scrape', { json })
.json<firecrawl.ScrapeResponse>()
if (!res.success || !res.data) return res
if (res.data.markdown) {
delete res.data.html
delete res.data.content
}
return res
}
async search(