Ejemplo n.º 1
0
 def _load(self):
     raw_source = self.__raw_source
     self.__elem_node = Html.from_str(raw_source, partial=self.__partial)
     self.__node = self.__elem_node.clone()
     self.__text_content = self.__elem_node.normalized_text
     self.__inner_html = self.__elem_node.normalized_inner_html
     self.__full_source = raw_source
     self.__elem_node.remove_all_children()
     self.__self_source = self.__elem_node.normalized_source
     self._content = GuiSourceContent(all=self.__full_source, root=self.__self_source, inner=self.__inner_html, text=self.__text_content)
     self._process_elem_node(self.__elem_node)
Ejemplo n.º 2
0
 def _load_part_content(self, part):
     # Code heavily taken from https://www.thepythoncode.com/article/reading-emails-in-python
     content_type = part.get_content_type()
     content_disposition = str(part.get("Content-Disposition"))
     try:
         # Email body
         body = part.get_payload(decode=True).decode()
     except:
         return
     if "attachment" not in content_disposition:
         if content_type == "multipart/alternative":
             pass
         elif content_type == "text/plain":
             from arjuna.tpi.parser.text import Text
             self.__contents.append(Text(body))
         elif content_type == "text/html":
             from arjuna.tpi.parser.html import Html
             self.__contents.append(Html.from_str(body))
         else:
             print("Unsupported email content type.", content_type)
             # Unsupported content type
             pass
     else:
         pass
Ejemplo n.º 3
0
 def html(self) -> 'HtmlNode':
     ''' 
         HTTP Response content as Arjuna's `HtmlNode` object.
     '''
     return Html.from_str(self.text)