def get_document(self, result, parser=None, encoding=None): from io import BytesIO buf = BytesIO(result.read().replace('\0', '')) return Browser.get_document(self, buf, parser, encoding)