當前位置: 首頁>>代碼示例>>Python>>正文


Python sgmllib.SGMLParseError方法代碼示例

本文整理匯總了Python中sgmllib.SGMLParseError方法的典型用法代碼示例。如果您正苦於以下問題:Python sgmllib.SGMLParseError方法的具體用法?Python sgmllib.SGMLParseError怎麽用?Python sgmllib.SGMLParseError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sgmllib的用法示例。


在下文中一共展示了sgmllib.SGMLParseError方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: parse_declaration

# 需要導入模塊: import sgmllib [as 別名]
# 或者: from sgmllib import SGMLParseError [as 別名]
def parse_declaration(self, i):
        """Treat a bogus SGML declaration as raw data. Treat a CDATA
        declaration as a CData object."""
        j = None
        if self.rawdata[i:i+9] == '<![CDATA[':
             k = self.rawdata.find(']]>', i)
             if k == -1:
                 k = len(self.rawdata)
             data = self.rawdata[i+9:k]
             j = k+3
             self._toStringSubclass(data, CData)
        else:
            try:
                j = SGMLParser.parse_declaration(self, i)
            except SGMLParseError:
                toHandle = self.rawdata[i:]
                self.handle_data(toHandle)
                j = i + len(toHandle)
        return j 
開發者ID:Autodesk,項目名稱:arnold-usd,代碼行數:21,代碼來源:__init__.py

示例2: dopage

# 需要導入模塊: import sgmllib [as 別名]
# 或者: from sgmllib import SGMLParseError [as 別名]
def dopage(self, url_pair):

        # All printing of URLs uses format_url(); argument changed to
        # url_pair for clarity.
        if self.verbose > 1:
            if self.verbose > 2:
                self.show("Check ", self.format_url(url_pair),
                          "  from", self.todo[url_pair])
            else:
                self.message("Check %s", self.format_url(url_pair))
        url, local_fragment = url_pair
        if local_fragment and self.nonames:
            self.markdone(url_pair)
            return
        try:
            page = self.getpage(url_pair)
        except sgmllib.SGMLParseError, msg:
            msg = self.sanitize(msg)
            self.note(0, "Error parsing %s: %s",
                          self.format_url(url_pair), msg)
            # Dont actually mark the URL as bad - it exists, just
            # we can't parse it!
            page = None 
開發者ID:aliyun,項目名稱:oss-ftp,代碼行數:25,代碼來源:webchecker.py

示例3: parse_declaration

# 需要導入模塊: import sgmllib [as 別名]
# 或者: from sgmllib import SGMLParseError [as 別名]
def parse_declaration(self, i):
        """Treat a bogus SGML declaration as raw data. Treat a CDATA
        declaration as a CData object."""
        j = None
        if self.rawdata[i:i+9] == '<![CDATA[':
             k = self.rawdata.find(']]>', i)
             if k == -1:
                 k = len(self.rawdata)
             data = self.rawdata[i+9:k]
             j = k+3
             self._toStringSubclass(data, CData)
        else:
            try:
                j = sgmllib.SGMLParser.parse_declaration(self, i)
            except sgmllib.SGMLParseError:
                toHandle = self.rawdata[i:]
                self.handle_data(toHandle)
                j = i + len(toHandle)
        return j 
開發者ID:MrH0wl,項目名稱:Cloudmare,代碼行數:21,代碼來源:beautifulsoup-bk.py


注:本文中的sgmllib.SGMLParseError方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。