Skip to content

Commit

Permalink
🚋
Browse files Browse the repository at this point in the history
  • Loading branch information
transitive-bullshit committed Jun 19, 2024
1 parent f8cd522 commit 3ccd56a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/services/scraper-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export namespace scraper {
strict: true
})

export type ScrapeResult = {
export type ScrapeResult = Partial<{
author: string
byline: string
description: string
Expand All @@ -36,7 +36,7 @@ export namespace scraper {

/** The text for the main content of the page. */
textContent: string
}
}>
}

/**
Expand Down Expand Up @@ -97,7 +97,7 @@ export class ScraperClient extends AIFunctionsProvider {
format?: 'html' | 'markdown' | 'plaintext' | 'all'
timeoutMs?: number
}
): Promise<Partial<scraper.ScrapeResult>> {
): Promise<scraper.ScrapeResult> {
const {
timeoutMs = 60_000,
format = 'markdown',
Expand All @@ -111,7 +111,7 @@ export class ScraperClient extends AIFunctionsProvider {
})
.json<scraper.ScrapeResult>()

if (res.length <= 40) {
if (res.length && res.length <= 40) {
try {
const message = (JSON.parse(res.textContent as string) as any).message
throw new Error(`Failed to scrape URL "${opts.url}": ${message}`)
Expand Down

0 comments on commit 3ccd56a

Please sign in to comment.