diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2019-06-16 07:07:54 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-16 07:07:54 (GMT) |
commit | 58a1a76baefc92d9e2392a5dbf65e39e44fb8f55 (patch) | |
tree | 04b3001a1bc09863fcd62a0442d0da2445ad0fba /Lib/urllib/robotparser.py | |
parent | a8e7ebe2880f4c1d3b91d40b9730bb4032d514d0 (diff) | |
download | cpython-58a1a76baefc92d9e2392a5dbf65e39e44fb8f55.zip cpython-58a1a76baefc92d9e2392a5dbf65e39e44fb8f55.tar.gz cpython-58a1a76baefc92d9e2392a5dbf65e39e44fb8f55.tar.bz2 |
bpo-35922: Fix RobotFileParser when robots.txt has no relevant crawl delay or request rate (GH-11791)
Co-Authored-By: Tal Einat <taleinat+github@gmail.com>
(cherry picked from commit 8047e0e1c620f69cc21f9ca48b24bf2cdd5c3668)
Co-authored-by: Rémi Lapeyre <remi.lapeyre@henki.fr>
Diffstat (limited to 'Lib/urllib/robotparser.py')
-rw-r--r-- | Lib/urllib/robotparser.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/urllib/robotparser.py b/Lib/urllib/robotparser.py index 7089916..c58565e 100644 --- a/Lib/urllib/robotparser.py +++ b/Lib/urllib/robotparser.py @@ -186,7 +186,9 @@ class RobotFileParser: for entry in self.entries: if entry.applies_to(useragent): return entry.delay - return self.default_entry.delay + if self.default_entry: + return self.default_entry.delay + return None def request_rate(self, useragent): if not self.mtime(): @@ -194,7 +196,9 @@ class RobotFileParser: for entry in self.entries: if entry.applies_to(useragent): return entry.req_rate - return self.default_entry.req_rate + if self.default_entry: + return self.default_entry.req_rate + return None def site_maps(self): if not self.sitemaps: |