| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 18735fd commit d35cfee
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -65,9 +65,17 @@ def read(self): | |||
| 65 | 65 | f = urllib.request.urlopen(self.url) | |
| 66 | 66 | except urllib.error.HTTPError as err: | |
| 67 | 67 | if err.code in (401, 403): | |
| 68 | + # If access to robot.txt has the status Unauthorized/Forbidden, | ||
| 69 | + # then most likely this applies to the entire site. | ||
| 68 | 70 | self.disallow_all = True | |
| 69 | - elif err.code >= 400 and err.code < 500: | ||
| 71 | + elif 400 <= err.code < 500: | ||
| 72 | + # RFC 9309, Section 2.3.1.3: the crawler MAY access any | ||
| 73 | + # resources on the server. | ||
| 70 | 74 | self.allow_all = True | |
| 75 | + elif 500 <= err.code < 600: | ||
| 76 | + # RFC 9309, Section 2.3.1.4: the crawler MUST assume | ||
| 77 | + # complete disallow. | ||
| 78 | + self.disallow_all = True | ||
| 71 | 79 | err.close() | |
| 72 | 80 | else: | |
| 73 | 81 | raw = f.read() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,2 @@ | |||
| 1 | + Disallow all access in :mod:`urllib.robotparser` if the ``robots.txt`` file | ||
| 2 | + is unreachable due to server or network errors. | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments