|
@ -273,8 +273,8 @@ export class ManualService implements DataProviderInterface { |
|
|
private async scrape( |
|
|
private async scrape( |
|
|
scraperConfiguration: ScraperConfiguration |
|
|
scraperConfiguration: ScraperConfiguration |
|
|
): Promise<number> { |
|
|
): Promise<number> { |
|
|
try { |
|
|
|
|
|
let locale = scraperConfiguration.locale; |
|
|
let locale = scraperConfiguration.locale; |
|
|
|
|
|
|
|
|
const response = await fetch(scraperConfiguration.url, { |
|
|
const response = await fetch(scraperConfiguration.url, { |
|
|
headers: scraperConfiguration.headers as HeadersInit, |
|
|
headers: scraperConfiguration.headers as HeadersInit, |
|
|
signal: AbortSignal.timeout( |
|
|
signal: AbortSignal.timeout( |
|
@ -282,8 +282,9 @@ export class ManualService implements DataProviderInterface { |
|
|
) |
|
|
) |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
if (response.headers['content-type'].includes('application/json')) { |
|
|
if (response.headers['content-type']?.includes('application/json')) { |
|
|
const data = await response.json(); |
|
|
const data = await response.json(); |
|
|
|
|
|
|
|
|
const value = String( |
|
|
const value = String( |
|
|
jsonpath.query(data, scraperConfiguration.selector)[0] |
|
|
jsonpath.query(data, scraperConfiguration.selector)[0] |
|
|
); |
|
|
); |
|
@ -303,8 +304,5 @@ export class ManualService implements DataProviderInterface { |
|
|
value: $(scraperConfiguration.selector).first().text() |
|
|
value: $(scraperConfiguration.selector).first().text() |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
} catch (error) { |
|
|
|
|
|
throw error; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|