Skip to content

Commit

Permalink
Merge pull request #16 from mborho/master
Browse files Browse the repository at this point in the history
Optimizing charset check.
  • Loading branch information
psolbach committed Jun 4, 2018
2 parents 8ef4ffb + c23e20a commit 567f487
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions metadoc/__init__.py
Expand Up @@ -187,8 +187,9 @@ def _request_url(self):
raise Exception('Requesting article body failed with {} status code.'.format(req.status_code))

# 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
enc_apparent = req.apparent_encoding.lower()
if req.encoding.lower() != enc_apparent and \
enc_apparent != "windows-1254":
logger.info("Switching html encoding: {} -> {}".format(req.encoding, enc_apparent))
req.encoding = enc_apparent
return req.text

0 comments on commit 567f487

Please sign in to comment.