Skip to main content
Version: 3.6

createLinkeDOMRouter

Callable


  • Creates new Router instance that works based on request labels. This instance can then serve as a requestHandler of your LinkeDOMCrawler. Defaults to the LinkeDOMCrawlingContext.

    Serves as a shortcut for using Router.create<LinkeDOMCrawlingContext>().

    import { LinkeDOMCrawler, createLinkeDOMRouter } from 'crawlee';

    const router = createLinkeDOMRouter();
    router.addHandler('label-a', async (ctx) => {
    ctx.log.info('...');
    });
    router.addDefaultHandler(async (ctx) => {
    ctx.log.info('...');
    });

    const crawler = new LinkeDOMCrawler({
    requestHandler: router,
    });
    await crawler.run();

    Type parameters

    Parameters

    Returns RouterHandler<Context>