MCPcopy Index your code
hub / github.com/1Panel-dev/MaxKB / get_encoding

Function get_encoding

apps/common/handle/impl/text/html_split_handle.py:29–37  ·  view source on GitHub ↗
(buffer)

Source from the content-addressed store, hash-verified

27
28
29def get_encoding(buffer):
30 beautiful_soup = BeautifulSoup(buffer, "html.parser")
31 meta_list = beautiful_soup.find_all('meta')
32 charset_list = [meta.attrs.get('charset') for meta in meta_list if
33 meta.attrs is not None and 'charset' in meta.attrs]
34 if len(charset_list) > 0:
35 charset = charset_list[0]
36 return charset
37 return detect(buffer)['encoding']
38
39
40class HTMLSplitHandle(BaseSplitHandle):

Callers 2

handleMethod · 0.85
get_contentMethod · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected