parsererror是什么意思中文翻译python-Python etree.ParserError方法代码示例

parsererror是什么意思中文翻译python-Python etree.ParserError方法代码示例本文整理汇总了Python中lxml.etree.ParserError方法的典型用法代码示例。如果您正苦于以下问题:Pythonetree.ParserError方法的具体用法?Pythonetree.ParserError怎么用?Pythonetree.ParserError使用的例子?那么恭喜您,这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在模块lxml.e…

大家好,又见面了,我是你们的朋友全栈君。

本文整理汇总了Python中lxml.etree.ParserError方法的典型用法代码示例。如果您正苦于以下问题:Python etree.ParserError方法的具体用法?Python etree.ParserError怎么用?Python etree.ParserError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在模块lxml.etree的用法示例。

在下文中一共展示了etree.ParserError方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: feed

​点赞 6

# 需要导入模块: from lxml import etree [as 别名]

# 或者: from lxml.etree import ParserError [as 别名]

def feed(self, markup):

if isinstance(markup, bytes):

markup = BytesIO(markup)

elif isinstance(markup, unicode):

markup = StringIO(markup)

# Call feed() at least once, even if the markup is empty,

# or the parser won”t be initialized.

data = markup.read(self.CHUNK_SIZE)

try:

self.parser = self.parser_for(self.soup.original_encoding)

self.parser.feed(data)

while len(data) != 0:

# Now call feed() on the rest of the data, chunk by chunk.

data = markup.read(self.CHUNK_SIZE)

if len(data) != 0:

self.parser.feed(data)

self.parser.close()

except (UnicodeDecodeError, LookupError, etree.ParserError), e:

raise ParserRejectedMarkup(str(e))

开发者ID:MarcelloLins,项目名称:ServerlessCrawler-VancouverRealState,代码行数:22,

示例2: feed

​点赞 6

# 需要导入模块: from lxml import etree [as 别名]

# 或者: from lxml.etree import ParserError [as 别名]

def feed(self, markup):

if isinstance(markup, bytes):

markup = BytesIO(markup)

elif isinstance(markup, str):

markup = StringIO(markup)

# Call feed() at least once, even if the markup is empty,

# or the parser won”t be initialized.

data = markup.read(self.CHUNK_SIZE)

try:

self.parser = self.parser_for(self.soup.original_encoding)

self.parser.feed(data)

while len(data) != 0:

# Now call feed() on the rest of the data, chunk by chunk.

data = markup.read(self.CHUNK_SIZE)

if len(data) != 0:

self.parser.feed(data)

self.parser.close()

except (UnicodeDecodeError, LookupError, etree.ParserError) as e:

raise ParserRejectedMarkup(str(e))

开发者ID:the-ethan-hunt,项目名称:B.E.N.J.I.,代码行数:22,

示例3: extract_html_content

​点赞 6

# 需要导入模块: from lxml import etree [as 别名]

# 或者: from lxml.etree import ParserError [as 别名]

def extract_html_content(self, html_body, fix_html=True):

“””Ingestor implementation.”””

if html_body is None:

return

try:

try:

doc = html.fromstring(html_body)

except ValueError:

# Ship around encoding declarations.

# https://stackoverflow.com/questions/3402520

html_body = self.RE_XML_ENCODING.sub(“”, html_body, count=1)

doc = html.fromstring(html_body)

except (ParserError, ParseError, ValueError):

raise ProcessingException(“HTML could not be parsed.”)

self.extract_html_header(doc)

self.cleaner(doc)

text = self.extract_html_text(doc)

self.result.flag(self.result.FLAG_HTML)

self.result.emit_html_body(html_body, text)

开发者ID:occrp-attic,项目名称:ingestors,代码行数:22,

示例4: ingest

​点赞 6

# 需要导入模块: from lxml import etree [as 别名]

# 或者: from lxml.etree import ParserError [as 别名]

def ingest(self, file_path):

“””Ingestor implementation.”””

file_size = self.result.size or os.path.getsize(file_path)

if file_size > self.MAX_SIZE:

raise ProcessingException(“XML file is too large.”)

try:

doc = etree.parse(file_path)

except (ParserError, ParseError):

raise ProcessingException(“XML could not be parsed.”)

text = self.extract_html_text(doc.getroot())

transform = etree.XSLT(self.XSLT)

html_doc = transform(doc)

html_body = html.tostring(html_doc, encoding=str, pretty_print=True)

self.result.flag(self.result.FLAG_HTML)

self.result.emit_html_body(html_body, text)

开发者ID:occrp-attic,项目名称:ingestors,代码行数:19,

示例5: _retrieve_html_page

​点赞 6

# 需要导入模块: from lxml import etree [as 别名]

# 或者: from lxml.etree import ParserError [as 别名]

def _retrieve_html_page(self):

“””

Download the requested player”s stats page.

Download the requested page and strip all of the comment tags before

returning a PyQuery object which will be used to parse the data.

Oftentimes, important data is contained in tables which are hidden in

HTML comments and not accessible via PyQuery.

Returns

——-

PyQuery object

The requested page is returned as a queriable PyQuery object with

the comment tags removed.

“””

url = self._build_url()

try:

url_data = pq(url)

except (HTTPError, ParserError):

return None

# For NFL, a 404 page doesn”t actually raise a 404 error, so it needs

# to be manually checked.

if “Page Not Found (404 error)” in str(url_data):

return None

return pq(utils._remove_html_comment_tags(url_data))

开发者ID:roclark,项目名称:sportsreference,代码行数:27,

示例6: _retrieve_html_page

​点赞 6

# 需要导入模块: from lxml import etree [as 别名]

# 或者: from lxml.etree import ParserError [as 别名]

def _retrieve_html_page(self):

“””

Download the requested player”s stats page.

Download the requested page and strip all of the comment tags before

returning a pyquery object which will be used to parse the data.

Returns

——-

PyQuery object

The requested page is returned as a queriable PyQuery object with

the comment tags removed.

“””

url = self._build_url()

try:

url_data = pq(url)

except (HTTPError, ParserError):

return None

return pq(utils._remove_html_comment_tags(url_data))

开发者ID:roclark,项目名称:sportsreference,代码行数:21,

示例7: _retrieve_html_page

​点赞 6

# 需要导入模块: from lxml import etree [as 别名]

# 或者: from lxml.etree import ParserError [as 别名]

def _retrieve_html_page(self):

“””

Download the requested player”s stats page.

Download the requested page and strip all of the comment tags before

returning a pyquery object which will be used to parse the data.

Returns

——-

PyQuery object

The requested page is returned as a queriable PyQuery object with

the comment tags removed.

“””

url = PLAYER_URL % self._player_id

try:

url_data = pq(url)

except (HTTPError, ParserError):

return None

return pq(utils._remove_html_comment_tags(url_data))

开发者ID:roclark,项目名称:sportsreference,代码行数:21,

示例8: _pull_conference_page

​点赞 6

# 需要导入模块: from lxml import etree [as 别名]

# 或者: from lxml.etree import ParserError [as 别名]

def _pull_conference_page(self, conference_abbreviation, year):

“””

Download the conference page.

Download the conference page for the requested conference and season

and create a PyQuery object.

Parameters

———-

conference_abbreviation : string

A string of the requested conference”s abbreviation, such as

“big-12”.

year : string

A string of the requested year to pull conference information from.

“””

try:

return pq(CONFERENCE_URL % (conference_abbreviation, year))

except (HTTPError, ParserError):

return None

开发者ID:roclark,项目名称:sportsreference,代码行数:21,

示例9: feed

​点赞 6

# 需要导入模块: from lxml import etree [as 别名]

# 或者: from lxml.etree import ParserError [as 别名]

def feed(self, markup):

if isinstance(markup, bytes):

markup = BytesIO(markup)

elif isinstance(markup, str):

markup = StringIO(markup)

# Call feed() at least once, even if the markup is empty,

# or the parser won”t be initialized.

data = markup.read(self.CHUNK_SIZE)

try:

self.parser = self.parser_for(self.soup.original_encoding)

self.parser.feed(data)

while len(data) != 0:

# Now call feed() on the rest of the data, chunk by chunk.

data = markup.read(self.CHUNK_SIZE)

if len(data) != 0:

self.parser.feed(data)

self.parser.close()

except (UnicodeDecodeError, LookupError, etree.ParserError) as e:

raise ParserRejectedMarkup(e)

开发者ID:Tautulli,项目名称:Tautulli,代码行数:22,

注:本文中的lxml.etree.ParserError方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/149151.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • RewriteCond RewriteRule

    RewriteCond RewriteRule##RulesforTRandEScountrysitesRewriteCond%{REQUEST_URI}^/(tr|es)$[NC]RewriteRule^(.*)https://xx.com[L,R=301]####Rulesfortheoldalias/sam/*RewriteRule^pp/(.*)/xx-p/$1…

    2022年5月27日
    27
  • bot抢鞋软件推荐_国内bot抢鞋软件

    bot抢鞋软件推荐_国内bot抢鞋软件自动抢鞋软件bot是一款超级易于使用的抢鞋工具软件。您可以在这里关注最新最时尚鞋。时尚潮流爱好者都可以关注它。您可以轻松地发现更多时尚的新鞋。如果您要寻找的鞋子,可以直接在线下订单。在这个时候,软件会自动帮你争取速度了。您可以及时关注有关时尚鞋预售的信息。抢鞋机器人bot特色1、抢鞋机器人bot软件是一款超级好用的掌上抢鞋神器,一键快速抢鞋;2、自己拼不过大家的手速,现在就可以靠机器人为你解决,各…

    2022年4月20日
    104
  • 社交网络大数据建模的框架探索「建议收藏」

    社交网络大数据建模的框架探索「建议收藏」社交网络大数据建模的框架探索本报告首先简略回顾腾讯社交网络的研究及应用成果,然后从尚未充分解决的若干问题出发,分析潜在问题和当前方法局限,对更一般性社交网络的建模给出一些思路建议,包括对最新计算智能技术的采用。接着提出理想中的模型框架,以及理想的模型框架探索方式。最后,对社交网络数据的应用潜力做出展望。详细解读和小伙伴们一起来吐槽

    2022年5月15日
    42
  • WDS 动手实验手册

    WDS 动手实验手册

    2021年8月2日
    53
  • c语言中字符串比较的库函数是什么_c语言比较字符串大小

    c语言中字符串比较的库函数是什么_c语言比较字符串大小在单片机串口实现字符串命令解析这篇文章中分析了在串口通信中如何去解析字符串命令,这篇文章就来讨论下字符串比较的方法都有哪些?说起比较运算,肯定第一时间想到了C语言中关于比较的相关运算符“>、<、!=、>=、<=、==”,那么要比较两个字符串是否相等是不是直接用“==”比较就行了。下面就来看看这种方法行不行?先看一个例子voidmain(void){chars1[]=”abc”;chars2[]…

    2025年7月24日
    2
  • Java数据结构与算法(排序)——基数排序(LSD)

    Java数据结构与算法(排序)——基数排序(LSD)一、基本思想先从最低位开始排序,再对次低位排序,直到对最高位排序后得到一个有序序列(位数不同时高位补0)。二、举例分析假设有一串数列:73,22,93,43,55,14,28,65,39,81。排序过程如下:(1)先根据个位进行排序,得到:0——1——812——223——73,93,434——145——55,656——7——8——289——39(2…

    2022年5月6日
    45

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号