-
Notifications
You must be signed in to change notification settings - Fork 10.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update dont_filter param within request-response.rst #6401
Open
bmazaoreg
wants to merge
1
commit into
scrapy:master
Choose a base branch
from
bmazaoreg:master
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Increased the accuracy of the dont_filter param docs description
Gallaecio
reviewed
Jun 12, 2024
Comment on lines
+147
to
+165
:param dont_filter: indicates that this request should not be dropped by any | ||
middleware or the scheduler. This parameter is crucial for scenarios where you | ||
wish to ensure that a request is processed even if it has been seen before, bypassing | ||
both the scheduler's duplicate filtering mechanism and any built-in or third-party | ||
middleware filters designed to prevent repeated processing. It is particularly useful in | ||
complex scraping projects where certain requests need to be retried under specific conditions, | ||
regardless of whether they have been previously processed. However, caution should be | ||
exercised when using this option, as improper usage can lead to infinite crawling loops. | ||
The default value is ``False``, meaning requests are subject to filtering unless explicitly instructed otherwise. | ||
|
||
Built-in Middlewares that take 'dont_filter' into account: | ||
|
||
- OffSiteMiddleware: Filters out requests for URLs outside the domains covered by the spider. | ||
If the request has the `dont_filter` attribute set, the offsite middleware will allow the | ||
request even if its domain is not listed in allowed domains | ||
|
||
- DepthMiddleware: Tracks the depth of each request inside the site being scraped. It sets | ||
`request.meta['depth'] = 0` whenever there is no value previously set and increments it by 1 otherwise. | ||
The `dont_filter` attribute can influence how requests are prioritized based on their depth |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can keep it much shorter without losing much information. Also, looking at the code, it does not look like DepthMiddleware
respects dont_filter
.
Suggested change
:param dont_filter: indicates that this request should not be dropped by any | |
middleware or the scheduler. This parameter is crucial for scenarios where you | |
wish to ensure that a request is processed even if it has been seen before, bypassing | |
both the scheduler's duplicate filtering mechanism and any built-in or third-party | |
middleware filters designed to prevent repeated processing. It is particularly useful in | |
complex scraping projects where certain requests need to be retried under specific conditions, | |
regardless of whether they have been previously processed. However, caution should be | |
exercised when using this option, as improper usage can lead to infinite crawling loops. | |
The default value is ``False``, meaning requests are subject to filtering unless explicitly instructed otherwise. | |
Built-in Middlewares that take 'dont_filter' into account: | |
- OffSiteMiddleware: Filters out requests for URLs outside the domains covered by the spider. | |
If the request has the `dont_filter` attribute set, the offsite middleware will allow the | |
request even if its domain is not listed in allowed domains | |
- DepthMiddleware: Tracks the depth of each request inside the site being scraped. It sets | |
`request.meta['depth'] = 0` whenever there is no value previously set and increments it by 1 otherwise. | |
The `dont_filter` attribute can influence how requests are prioritized based on their depth | |
:param dont_filter: indicates whether :ref:`components <topics-components>` | |
may drop this request (``False``, default) or not (``True``). | |
:ref:`Built-in schedulers <topics-scheduler>` (which by default drop | |
duplicate requests) and | |
:class:`~scrapy.downloadermiddlewares.offsite.OffSiteMiddleware` | |
respect this parameter. Some third-party components may also respect | |
it. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This request updates the dont_filter param documentation to increase its accuracy as suggested in #6398
A description of what the param is asking, as well as a list of built-in middlewares that take this into account are added.
Resolves #6398