本文整理汇总了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
示例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
示例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