Python bs4.element 模块,Comment() 实例源码

我们从Python开源项目中,提取了以下19个代码示例,用于说明如何使用bs4.element.Comment()

项目:Gank-Alfred-Workflow    作者:hujiaweibujidao    | 项目源码 | 文件源码
def comment(self, content):
        "Handle comments as Comment objects."
        self.soup.endData()
        self.soup.handle_data(content)
        self.soup.endData(Comment)
项目:Taigabot    作者:FrozenPigs    | 项目源码 | 文件源码
def comment(self, content):
        "Handle comments as Comment objects."
        self.soup.endData()
        self.soup.handle_data(content)
        self.soup.endData(Comment)
项目:Crunchyroll-XML-Decoder    作者:jaw20    | 项目源码 | 文件源码
def comment(self, content):
        "Handle comments as Comment objects."
        self.soup.endData()
        self.soup.handle_data(content)
        self.soup.endData(Comment)
项目:catchup4kodi    作者:catchup4kodi    | 项目源码 | 文件源码
def comment(self, content):
        "Handle comments as Comment objects."
        self.soup.endData()
        self.soup.handle_data(content)
        self.soup.endData(Comment)
项目:script.quasar.t411-rik91    作者:rik91    | 项目源码 | 文件源码
def comment(self, content):
        "Handle comments as Comment objects."
        self.soup.endData()
        self.soup.handle_data(content)
        self.soup.endData(Comment)
项目:-PunkScan    作者:swordli    | 项目源码 | 文件源码
def comment(self, content):
        "Handle comments as Comment objects."
        self.soup.endData()
        self.soup.handle_data(content)
        self.soup.endData(Comment)
项目:-PunkScan    作者:swordli    | 项目源码 | 文件源码
def comment(self, content):
        "Handle comments as Comment objects."
        self.soup.endData()
        self.soup.handle_data(content)
        self.soup.endData(Comment)
项目:gerador-horarios    作者:colobas    | 项目源码 | 文件源码
def comment(self, content):
        "Handle comments as Comment objects."
        self.soup.endData()
        self.soup.handle_data(content)
        self.soup.endData(Comment)
项目:punkspider    作者:aiwennba    | 项目源码 | 文件源码
def comment(self, content):
        "Handle comments as Comment objects."
        self.soup.endData()
        self.soup.handle_data(content)
        self.soup.endData(Comment)
项目:punkspider    作者:aiwennba    | 项目源码 | 文件源码
def comment(self, content):
        "Handle comments as Comment objects."
        self.soup.endData()
        self.soup.handle_data(content)
        self.soup.endData(Comment)
项目:zpretty    作者:collective    | 项目源码 | 文件源码
def is_comment(self):
        ''' Check if this element is a comment
        '''
        return isinstance(self.context, Comment)
项目:open-safari-simulator-applescript    作者:realjade    | 项目源码 | 文件源码
def comment(self, content):
        "Handle comments as Comment objects."
        self.soup.endData()
        self.soup.handle_data(content)
        self.soup.endData(Comment)
项目:AstroCoffee    作者:abhimat    | 项目源码 | 文件源码
def comment(self, content):
        "Handle comments as Comment objects."
        self.soup.endData()
        self.soup.handle_data(content)
        self.soup.endData(Comment)
项目:sack    作者:jofpin    | 项目源码 | 文件源码
def test_cdata_where_it_doesnt_belong(self):
        # Random CDATA sections are converted into comments.
        markup = "<div><![CDATA[foo]]>"
        soup = self.soup(markup)
        data = soup.find(text="[CDATA[foo]]")
        self.assertEqual(data.__class__, Comment)
项目:sack    作者:jofpin    | 项目源码 | 文件源码
def test_incomplete_declaration(self):
        # An incomplete declaration is treated as a comment.
        markup = 'a<!b <p>c'
        self.assertSoupEquals(markup, "a<!--b <p-->c")

        # Let's spell that out a little more explicitly.
        soup = self.soup(markup)
        str1, comment, str2 = soup.body.contents
        self.assertEqual(str1, 'a')
        self.assertEqual(comment.__class__, Comment)
        self.assertEqual(comment, 'b <p')
        self.assertEqual(str2, 'c')
项目:sack    作者:jofpin    | 项目源码 | 文件源码
def test_document_starts_with_bogus_declaration(self):
        soup = self.soup('<! Foo >a')
        # 'Foo' becomes a comment that appears before the HTML.
        comment = soup.contents[0]
        self.assertTrue(isinstance(comment, Comment))
        self.assertEqual(comment, 'Foo')

        self.assertEqual(self.find(text="a") == "a")
项目:sack    作者:jofpin    | 项目源码 | 文件源码
def test_document_starts_with_bogus_declaration(self):
        soup = self.soup('<! Foo ><p>a</p>')
        # The declaration becomes a comment.
        comment = soup.contents[0]
        self.assertTrue(isinstance(comment, Comment))
        self.assertEqual(comment, ' Foo ')
        self.assertEqual(soup.p.string, 'a')
项目:sack    作者:jofpin    | 项目源码 | 文件源码
def test_document_ends_with_incomplete_declaration(self):
        soup = self.soup('<p>a<!b')
        # This becomes a string 'a'. The incomplete declaration is ignored.
        # Compare html5lib, which turns it into a comment.
        s, comment = soup.p.contents
        self.assertEqual(s, 'a')
        self.assertTrue(isinstance(comment, Comment))
        self.assertEqual(comment, 'b')
项目:sack    作者:jofpin    | 项目源码 | 文件源码
def comment(self, content):
        "Handle comments as Comment objects."
        self.soup.endData()
        self.soup.handle_data(content)
        self.soup.endData(Comment)