(buffer)
| 27 | |
| 28 | |
| 29 | def 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 | |
| 40 | class HTMLSplitHandle(BaseSplitHandle): |
no test coverage detected