MCPcopy Create free account
hub / github.com/ZiniuLu/Python-100-Days / decode_page

Function decode_page

Day66-75/code/main_redis.py:23–31  ·  view source on GitHub ↗
(page_bytes, charsets=('utf-8',))

Source from the content-addressed store, hash-verified

21
22
23def decode_page(page_bytes, charsets=('utf-8',)):
24 page_html = None
25 for charset in charsets:
26 try:
27 page_html = page_bytes.decode(charset)
28 break
29 except UnicodeDecodeError:
30 pass
31 return page_html
32
33
34class Retry(object):

Callers 1

fetchMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected