Exemplo n.º 1
0
 def parse(self, url, data=None, encoding=POM.DEFAULT_ENCODING,
                                 useragent=None, accept=None):
     from pycopia.WWW import urllibplus
     fo = urllibplus.urlopen(url, data, encoding, useragent=useragent, accept=accept)
     if logfile:
         from pycopia import UserFile
         fo = UserFile.FileWrapper(fo, logfile=logfile)
     return self.parse_orig(fo)
Exemplo n.º 2
0
def parse(filename_url_or_file, parser=None, encoding=None, useragent=None, accept=None):
    """Parse a filename, URL, or file-like object into an HTML document
    tree.  Note: this returns a tree, not an element.  Use
    ``parse(...).getroot()`` to get the document root.
    """
    if parser is None:
        parser = get_parser()
    if isinstance(filename_url_or_file, basestring):
        from pycopia.WWW import urllibplus
        fp = urllibplus.urlopen(filename_url_or_file, encoding=encoding, useragent=useragent, accept=accept)
    else:
        fp = filename_url_or_file
    return parser.parse(fp, useChardet=True)
Exemplo n.º 3
0
 def parse(self,
           url,
           data=None,
           encoding=POM.DEFAULT_ENCODING,
           useragent=None,
           accept=None):
     from pycopia.WWW import urllibplus
     fo = urllibplus.urlopen(url,
                             data,
                             encoding,
                             useragent=useragent,
                             accept=accept)
     self.parseFile(fo)
     self.close()
Exemplo n.º 4
0
 def parse(self,
           url,
           data=None,
           encoding=POM.DEFAULT_ENCODING,
           useragent=None,
           accept=None):
     from pycopia.WWW import urllibplus
     fo = urllibplus.urlopen(url,
                             data,
                             encoding,
                             useragent=useragent,
                             accept=accept)
     if logfile:
         from pycopia import UserFile
         fo = UserFile.FileWrapper(fo, logfile=logfile)
     return self.parse_orig(fo)
Exemplo n.º 5
0
def parse(filename_url_or_file,
          parser=None,
          encoding=None,
          useragent=None,
          accept=None):
    """Parse a filename, URL, or file-like object into an HTML document
    tree.  Note: this returns a tree, not an element.  Use
    ``parse(...).getroot()`` to get the document root.
    """
    if parser is None:
        parser = get_parser()
    if isinstance(filename_url_or_file, basestring):
        from pycopia.WWW import urllibplus
        fp = urllibplus.urlopen(filename_url_or_file,
                                encoding=encoding,
                                useragent=useragent,
                                accept=accept)
    else:
        fp = filename_url_or_file
    return parser.parse(fp, useChardet=True)
Exemplo n.º 6
0
 def parse(self, url, data=None, encoding=POM.DEFAULT_ENCODING, 
                                 useragent=None, accept=None):
     from pycopia.WWW import urllibplus
     fo = urllibplus.urlopen(url, data, encoding, useragent=useragent, accept=accept)
     self.parseFile(fo)
     self.close()