mirror of
https://github.com/soimort/you-get.git
synced 2025-02-11 12:42:29 +03:00
get encoding from response date
fix #622 Signed-off-by: Zhang Ning <zhangn1985@gmail.com>
This commit is contained in:
parent
25c769df2e
commit
9abf54ead5
@ -192,7 +192,8 @@ def get_content(url, headers={}, decoded=True):
|
||||
|
||||
# Decode the response body
|
||||
if decoded:
|
||||
charset = match1(response.getheader('Content-Type'), r'charset=([\w-]+)')
|
||||
charset = match1(response.getheader('Content-Type'), r'charset=([\w-]+)') or \
|
||||
match1(str(data), r'charset=([\w-]+)')
|
||||
if charset is not None:
|
||||
data = data.decode(charset)
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user