Apify Discord Mirror

Updated last year

Add label to pages via `crawler.addRequests()`?

At a glance

The community member is trying to add a page as the initial crawl target, but wants to add a label to ensure it routes to the correct processor. They note that they can only add RequestQueueOperationOptions with addRequests(), not the same EnqueueLinksOptions that they can use with enqueueLinks().

In the comments, other community members suggest creating a Request object and putting it into the array, where the label property can be used to add a label to the request.

Useful resources
I am adding a page as the initial crawl target, but would like to add a label to ensure it routes to the correct processor. Is there a way to do this?
Plain Text
await crawler.addRequests([  "https://www.foo.bar/page",
])

It seems I can only add RequestQueueOperationOptions with addRequests, not the same EnqueueLinksOptions that I can use with enqueueLinks().
N
H
2 comments
Create a Request object and put it into your array .
In the request object you can use label
Plain Text
await crawler.addRequests([{
    url: 'https://www.foo.bar/page,
    label: 'start-url',
}]);
Add a reply
Sign up and join the conversation on Discord