andreburgaud / robotspy Goto Github PK
View Code? Open in Web Editor NEWAlternative robots parser module for Python
Home Page: https://pypi.org/project/robotspy/
License: MIT License
Alternative robots parser module for Python
Home Page: https://pypi.org/project/robotspy/
License: MIT License
The current implementation of gen_uri would fail with an entry in the robots.txt line which isn't correctly encoded in 'utf-8' additionally it is assuming that all robots.txt files are encoded in 'utf-8' which isn't a safe option. The following version solves the problem:
def gen_uri(self, uri: str):
"""Instantiate a generator from a URI (either http:// or https:// or file:///"""
try:
with urllib.request.urlopen(uri) as f:
self._time = time.time()
encoding = f.headers.get_content_charset() or "utf-8"
for line in f:
try:
yield line.decode(encoding)
except UnicodeDecodeError:
yield line.decode("utf-8", "replace")
except urllib.error.HTTPError as err:
if err.code in (401, 403):
self.disallow_all = True
self._errors.append((str(err.code), str(err)))
elif 400 <= err.code < 500:
self.allow_all = True
self._warnings.append((str(err.code), str(err)))
self._time = 0
except urllib.error.URLError as err:
self._errors.append(("", str(err)))
I have tried to submit a pull request but I have no rights 😉
I need the source code of this website, I want to deploy a similar one, I wonder if I can share it?
Email:[email protected]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.