Skip to content
Merged
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: 6 additions & 1 deletion metadoc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,9 @@ def _request_url(self):
if req.status_code != 200:
raise Exception('Requesting article body failed with {} status code.'.format(req.status_code))

return req.text # after except
# check for encoding conflicts (e.g. t3n.de)
if req.encoding.lower() != req.apparent_encoding.lower() and \
req.apparent_encoding.lower() != "windows-1254":
logger.info("Switching html encoding: {} -> {}".format(req.encoding, req.apparent_encoding))
req.encoding = req.apparent_encoding
return req.text