当前位置: 首页>>代码示例>>Python>>正文


Python feedparser.FeedParser方法代码示例

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


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

示例1: parse

# 需要导入模块: from email import feedparser [as 别名]
# 或者: from email.feedparser import FeedParser [as 别名]
def parse(self, fp, headersonly=False):
        """Create a message structure from the data in a file.

        Reads all the data from the file and returns the root of the message
        structure.  Optional headersonly is a flag specifying whether to stop
        parsing after reading the headers or not.  The default is False,
        meaning it parses the entire contents of the file.
        """
        feedparser = FeedParser(self._class)
        if headersonly:
            feedparser._set_headersonly()
        while True:
            data = fp.read(8192)
            if not data:
                break
            feedparser.feed(data)
        return feedparser.close() 
开发者ID:glmcdona,项目名称:meddle,代码行数:19,代码来源:parser.py

示例2: parse

# 需要导入模块: from email import feedparser [as 别名]
# 或者: from email.feedparser import FeedParser [as 别名]
def parse(self, fp, headersonly=False):
        """Create a message structure from the data in a file.

        Reads all the data from the file and returns the root of the message
        structure.  Optional headersonly is a flag specifying whether to stop
        parsing after reading the headers or not.  The default is False,
        meaning it parses the entire contents of the file.
        """
        feedparser = FeedParser(self._class, policy=self.policy)
        if headersonly:
            feedparser._set_headersonly()
        while True:
            data = fp.read(8192)
            if not data:
                break
            feedparser.feed(data)
        return feedparser.close() 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:19,代码来源:parser.py

示例3: test_pushCR_LF

# 需要导入模块: from email import feedparser [as 别名]
# 或者: from email.feedparser import FeedParser [as 别名]
def test_pushCR_LF(self):
        '''FeedParser BufferedSubFile.push() assumed it received complete
           line endings.  A CR ending one push() followed by a LF starting
           the next push() added an empty line.
        '''
        imt = [
            ("a\r \n",  2),
            ("b",       0),
            ("c\n",     1),
            ("",        0),
            ("d\r\n",   1),
            ("e\r",     0),
            ("\nf",     1),
            ("\r\n",    1),
          ]
        from email.feedparser import BufferedSubFile, NeedMoreData
        bsf = BufferedSubFile()
        om = []
        nt = 0
        for il, n in imt:
            bsf.push(il)
            nt += n
            n1 = 0
            for ol in iter(bsf.readline, NeedMoreData):
                om.append(ol)
                n1 += 1
            self.assertEqual(n, n1)
        self.assertEqual(len(om), nt)
        self.assertEqual(''.join([il for il, n in imt]), ''.join(om)) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:31,代码来源:test_email.py

示例4: parse

# 需要导入模块: from email import feedparser [as 别名]
# 或者: from email.feedparser import FeedParser [as 别名]
def parse(self, chunks):
        from email.feedparser import FeedParser
        feedparser = FeedParser()
        for chunk in chunks:
            feedparser.feed(chunk)
        return feedparser.close() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:8,代码来源:test_email.py

示例5: test_partial_falls_inside_message_delivery_status

# 需要导入模块: from email import feedparser [as 别名]
# 或者: from email.feedparser import FeedParser [as 别名]
def test_partial_falls_inside_message_delivery_status(self):
        eq = self.ndiffAssertEqual
        # The Parser interface provides chunks of data to FeedParser in 8192
        # byte gulps.  SF bug #1076485 found one of those chunks inside
        # message/delivery-status header block, which triggered an
        # unreadline() of NeedMoreData.
        msg = self._msgobj('msg_43.txt')
        sfp = StringIO()
        iterators._structure(msg, sfp)
        eq(sfp.getvalue(), """\
multipart/report
    text/plain
    message/delivery-status
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
    text/rfc822-headers
""") 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:43,代码来源:test_email.py


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