summaryrefslogtreecommitdiffstats
path: root/Lib/urllib
diff options
context:
space:
mode:
authorBerker Peksag <berker.peksag@gmail.com>2016-09-18 17:17:58 (GMT)
committerBerker Peksag <berker.peksag@gmail.com>2016-09-18 17:17:58 (GMT)
commit9a7bbb2e3f12faaf4110ecd15fb739e94f4bc8f6 (patch)
tree0b8430da11ccc8beb8fc9d4c70780543de1e781e /Lib/urllib
parent85c98bf9682a46f7b15e9c79c68d38af8a9109b0 (diff)
downloadcpython-9a7bbb2e3f12faaf4110ecd15fb739e94f4bc8f6.zip
cpython-9a7bbb2e3f12faaf4110ecd15fb739e94f4bc8f6.tar.gz
cpython-9a7bbb2e3f12faaf4110ecd15fb739e94f4bc8f6.tar.bz2
Issue #25400: RobotFileParser now correctly returns default values for crawl_delay and request_rate
Initial patch by Peter Wirtz.
Diffstat (limited to 'Lib/urllib')
-rw-r--r--Lib/urllib/robotparser.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/urllib/robotparser.py b/Lib/urllib/robotparser.py
index 85add16..9dab4c1 100644
--- a/Lib/urllib/robotparser.py
+++ b/Lib/urllib/robotparser.py
@@ -175,16 +175,20 @@ class RobotFileParser:
return True
def crawl_delay(self, useragent):
+ if not self.mtime():
+ return None
for entry in self.entries:
if entry.applies_to(useragent):
return entry.delay
- return None
+ return self.default_entry.delay
def request_rate(self, useragent):
+ if not self.mtime():
+ return None
for entry in self.entries:
if entry.applies_to(useragent):
return entry.req_rate
- return None
+ return self.default_entry.req_rate
def __str__(self):
return ''.join([str(entry) + "\n" for entry in self.entries])