You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
robotparser should support specifying SSL context #87763
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=Nonecreated_at=<Date2021-03-22.23:08:07.176>labels= ['type-feature', 'library', '3.10']
title='robotparser should support specifying SSL context'updated_at=<Date2021-04-07.01:56:13.794>user='https://github.com/Tchinmai7'
IMO this could be enhanced by adding a sslcontext parameter to read method
a sample change would it could look like
def read(self, sslcontext=None):
"""Reads the robots.txt URL and feeds it to the parser."""
try:
if sslcontext:
f = urllib.request.urlopen(self.url, context=sslcontext)
else:
f = urllib.request.urlopen(self.url)
except urllib.error.HTTPError as err:
if err.code in (401, 403):
self.disallow_all = True
elif err.code >= 400 and err.code < 500:
self.allow_all = True
else:
raw = f.read()
self.parse(raw.decode("utf-8").splitlines())
I'm not opposing to the idea, but what's the practical use case here? I haven't seen a case where you needed to pass a custom SSLContext in order to fetch the robots.txt file.
I am writing a web scraper, that runs in a container that has CA-Certificates stored in a non-standard location. The Ca-Certificates are managed by Certifi. By allowing to override the sslcontext, it is possible for the user to construct a sslcontext and pass it in.
Activity
Tchinmai7 commentedon Mar 22, 2021
IMO this could be enhanced by adding a sslcontext parameter to read method
a sample change would it could look like
Happy to send a PR if this proposal makes sense.
berkerpeksag commentedon Apr 7, 2021
I'm not opposing to the idea, but what's the practical use case here? I haven't seen a case where you needed to pass a custom SSLContext in order to fetch the robots.txt file.
Tchinmai7 commentedon Apr 7, 2021
I am writing a web scraper, that runs in a container that has CA-Certificates stored in a non-standard location. The Ca-Certificates are managed by Certifi. By allowing to override the sslcontext, it is possible for the user to construct a sslcontext and pass it in.