Compare commits
2 Commits
285e1e5f42
...
325a373e3e
Author | SHA1 | Date |
---|---|---|
pictuga | 325a373e3e | |
pictuga | 2719bd6776 |
|
@ -149,6 +149,15 @@ class GZIPHandler(BaseHandler):
|
||||||
|
|
||||||
|
|
||||||
def detect_encoding(data, resp=None):
|
def detect_encoding(data, resp=None):
|
||||||
|
enc = detect_raw_encoding(data, resp)
|
||||||
|
|
||||||
|
if enc == 'gb2312':
|
||||||
|
enc = 'gbk'
|
||||||
|
|
||||||
|
return enc
|
||||||
|
|
||||||
|
|
||||||
|
def detect_raw_encoding(data, resp=None):
|
||||||
if resp is not None:
|
if resp is not None:
|
||||||
enc = resp.headers.get('charset')
|
enc = resp.headers.get('charset')
|
||||||
if enc is not None:
|
if enc is not None:
|
||||||
|
|
|
@ -100,7 +100,7 @@ def parse(data, url=None, mimetype=None, encoding=None):
|
||||||
try:
|
try:
|
||||||
feed = parser(data, encoding=encoding)
|
feed = parser(data, encoding=encoding)
|
||||||
|
|
||||||
except (ValueError):
|
except (ValueError, SyntaxError):
|
||||||
# parsing did not work
|
# parsing did not work
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue