EnqueueLinksFunction
Index
Methods
Methods
__call__
Call enqueue links function.
Parameters
optionalkeyword-onlyselector: str | None = None
A selector used to find the elements containing the links. The behaviour differs based on the crawler used:
PlaywrightCrawlersupports CSS and XPath selectors.ParselCrawlersupports CSS selectors.BeautifulSoupCrawlersupports CSS selectors.
optionalkeyword-onlylabel: str | None = None
Label for the newly created
Requestobjects, used for request routing.optionalkeyword-onlyuser_data: dict[str, Any] | None = None
User data to be provided to the newly created
Requestobjects.optionalkeyword-onlytransform_request_function: Callable[[RequestOptions], RequestOptions | RequestTransformAction] | None = None
A function that takes
RequestOptionsand returns either:- Modified
RequestOptionsto update the request configuration, 'skip'to exclude the request from being enqueued,'unchanged'to use the original request options without modification.
- Modified
optionalkeyword-onlyrequests: Sequence[str | Request] | None = None
Requests to be added to the
RequestManager.optionalkeyword-onlyrq_id: str | None = None
ID of the
RequestQueueto add the requests to. Only one ofrq_id,rq_nameorrq_aliascan be provided.optionalkeyword-onlyrq_name: str | None = None
Name of the
RequestQueueto add the requests to. Only one ofrq_id,rq_nameorrq_aliascan be provided.optionalkeyword-onlyrq_alias: str | None = None
Alias of the
RequestQueueto add the requests to. Only one ofrq_id,rq_nameorrq_aliascan be provided.keyword-onlyoptionallimit: int
Maximum number of requests to be enqueued.
keyword-onlyoptionalbase_url: str
Base URL to be used for relative URLs.
keyword-onlyoptionalstrategy: EnqueueStrategy
Enqueue strategy to be used for determining which links to extract and enqueue.
Options: all: Enqueue every link encountered, regardless of the target domain. Use this option to ensure that all links, including those leading to external websites, are followed. same-domain: Enqueue links that share the same domain name as the current page, including any subdomains. This strategy is ideal for crawling within the same top-level domain while still allowing for subdomain exploration. same-hostname: Enqueue links only if they match the exact hostname of the current page. This is the default behavior and restricts the crawl to the current hostname, excluding subdomains. same-origin: Enqueue links that share the same origin as the current page. The origin is defined by the combination of protocol, domain, and port, ensuring a strict scope for the crawl.
keyword-onlyoptionalinclude: list[re.Pattern | Glob]
List of regular expressions or globs that URLs must match to be enqueued.
keyword-onlyoptionalexclude: list[re.Pattern | Glob]
List of regular expressions or globs that URLs must not match to be enqueued.
Returns Coroutine[None, None, None]
A function for enqueueing new URLs to crawl based on elements selected by a given selector or explicit requests.
It adds explicitly passed
requeststo theRequestManageror it extracts URLs from the current page and enqueues them for further crawling. It allows filtering through selectors and other options. You can also specify labels and user data to be associated with the newly createdRequestobjects.It should not be called with
selector,label,user_dataortransform_request_functionarguments together withrequestsargument.For even more control over the enqueued links you can use combination of
ExtractLinksFunctionandAddRequestsFunction.