Files
2026-07-13 13:23:39 +08:00

25 lines
674 B
JavaScript

import { Actor, KeyValueStore } from 'apify';
import { BasicCrawler } from '@crawlee/basic';
const mainOptions = {
exit: Actor.isAtHome(),
storage:
process.env.STORAGE_IMPLEMENTATION === 'LOCAL'
? new (await import('@apify/storage-local')).ApifyStorageLocal()
: undefined,
};
await Actor.main(async () => {
const kv = await KeyValueStore.open();
const crawler = new BasicCrawler({
async requestHandler() {
const automaticValue = await kv.getAutoSavedValue('crawlee');
automaticValue.crawlee = 'awesome!';
},
});
await crawler.run(['https://example.com']);
}, mainOptions);