Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filtering out URLs whose parsing encounter UnicodeDecodeError #16

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions noisy.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ def _is_blacklisted(self, url):
:param url: full URL
:return: boolean indicating whether a URL is blacklisted or not
"""
return any(blacklisted_url in url for blacklisted_url in self._config["blacklisted_urls"])
try:
return any(blacklisted_url in url for blacklisted_url in self._config["blacklisted_urls"])
except UnicodeDecodeError:
return True

def _should_accept_url(self, url):
"""
Expand Down Expand Up @@ -171,7 +174,7 @@ def _browse_from_links(self, depth=0):
# remove the dead-end link from our list
self._remove_and_blacklist(random_link)

except requests.exceptions.RequestException:
except (requests.exceptions.RequestException, UnicodeDecodeError):
logging.debug("Exception on URL: %s, removing from list and trying again!" % random_link)
self._remove_and_blacklist(random_link)

Expand Down