mirror of
https://github.com/p-stream/providers.git
synced 2026-04-04 14:39:43 +00:00
17 lines
556 B
TypeScript
17 lines
556 B
TypeScript
import { makeProviders, makeSimpleProxyFetcher, makeStandardFetcher, targets } from '../../../lib';
|
|
|
|
(window as any).scrape = (proxyUrl: string, type: 'source' | 'embed', input: any) => {
|
|
const providers = makeProviders({
|
|
fetcher: makeStandardFetcher(fetch),
|
|
target: targets.BROWSER,
|
|
proxiedFetcher: makeSimpleProxyFetcher(proxyUrl, fetch),
|
|
});
|
|
if (type === 'source') {
|
|
return providers.runSourceScraper(input);
|
|
}
|
|
if (type === 'embed') {
|
|
return providers.runEmbedScraper(input);
|
|
}
|
|
|
|
throw new Error('Input input type');
|
|
};
|