-
Notifications
You must be signed in to change notification settings - Fork 349
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
feat!: Enable additional status codes arguments to PlaywrightCrawler #959
base: master
Are you sure you want to change the base?
Conversation
Since they exist now on all crawlers, move them to basic crawler level.
|
||
if self._http_client.additional_blocked_status_codes != self._additional_http_error_status_codes: | ||
raise ValueError( | ||
'Used `additional_blocked_status_codes` argument does not match with with ' |
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.
double with
Sorry, can't commit with the quick fix due to limited permissions.
self._additional_http_error_status_codes = ( | ||
set(additional_http_error_status_codes) if additional_http_error_status_codes else set() | ||
) | ||
self._ignore_http_error_status_codes = ( | ||
set(ignore_http_error_status_codes) if ignore_http_error_status_codes else set() | ||
) | ||
|
||
self._http_client = http_client or HttpxHttpClient( | ||
additional_http_error_status_codes=self._additional_http_error_status_codes, | ||
ignore_http_error_status_codes=self._ignore_http_error_status_codes, | ||
) | ||
|
||
if self._http_client.additional_blocked_status_codes != self._additional_http_error_status_codes: | ||
raise ValueError( | ||
'Used `additional_blocked_status_codes` argument does not match with ' | ||
f'{self._http_client.additional_blocked_status_codes=}. They have to be the same.' | ||
) | ||
if self._http_client.ignore_http_error_status_codes != self._ignore_http_error_status_codes: | ||
raise ValueError( | ||
'Used `ignore_http_error_status_codes` argument does not match with ' | ||
f'{self._http_client.ignore_http_error_status_codes=}. They have to be the same.' | ||
) |
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.
Couldn't we just keep them only in the http_client
instance? (PW Crawler has HTTP client as well)
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 was considering that option, but it felt like misuse to me, especially when it comes to PlaywrightCrawler. PlaywrightCrawler is not using HTTP client for page.navigate
so it would be really strange if it would use some attribute of this unrelated component to decide whether response status code of page.navigate
is ok or not.
(Mentioned : #953 (comment))
But I see it looks like unnecessary code duplication, so I am not 100% happy with this either.
Description
Add
additional_http_error_status_codes
andignore_http_error_status_codes
to PlaywrightCrawler.Since they exist now on all crawlers, move them to
BasicCrawler
level.Do not use
_http_client
attributes for getting additional status codes related variables.Breaking: Remove
HttpCrawlerOptions
-> No unique options compared toBasicCrawlerOptions
anymore.Issues