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


Python DOMImplementation.createHTMLElement方法代码示例

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


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

示例1: _getElementById_IE67

# 需要导入模块: from DOMImplementation import DOMImplementation [as 别名]
# 或者: from DOMImplementation.DOMImplementation import createHTMLElement [as 别名]
    def _getElementById_IE67(self, elementId):
        from DOMImplementation import DOMImplementation

        def _match_tag(tag, p):
            return p in tag.attrs and tag.attrs[p] == elementId

        def match_tag(tag, id):
            if _match_tag(tag, id):
                return True

            return False

        def filter_tags_id(tag):
            return tag.has_attr('id')

        def filter_tags_name(tag):
            return tag.has_attr('name')

        for tag in self.doc.find_all(filter_tags_id):
            if match_tag(tag, 'id'):
                return DOMImplementation.createHTMLElement(self, tag)

        for tag in self.doc.find_all(filter_tags_name):
            if match_tag(tag, 'name'):
                return DOMImplementation.createHTMLElement(self, tag)

        return None
开发者ID:Prithvirajbilla,项目名称:thug,代码行数:29,代码来源:Document.py

示例2: createElement

# 需要导入模块: from DOMImplementation import DOMImplementation [as 别名]
# 或者: from DOMImplementation.DOMImplementation import createHTMLElement [as 别名]
    def createElement(self, tagname):
        from DOMImplementation import DOMImplementation

        element = DOMImplementation.createHTMLElement(self, BeautifulSoup.Tag(parser = self.doc, name = tagname))
        if self.onCreateElement:
            self.onCreateElement(element)
        
        return element
开发者ID:chorsley,项目名称:thug,代码行数:10,代码来源:Document.py

示例3: namedItem

# 需要导入模块: from DOMImplementation import DOMImplementation [as 别名]
# 或者: from DOMImplementation.DOMImplementation import createHTMLElement [as 别名]
    def namedItem(self, name):
        from DOMImplementation import DOMImplementation

        for node in self.nodes:
            if node.nodeName == name:
                return DOMImplementation.createHTMLElement(self.doc, node) if node else None

        return None
开发者ID:Debug-Orz,项目名称:thug,代码行数:10,代码来源:HTMLCollection.py

示例4: _querySelector

# 需要导入模块: from DOMImplementation import DOMImplementation [as 别名]
# 或者: from DOMImplementation.DOMImplementation import createHTMLElement [as 别名]
    def _querySelector(self, selectors):
        from DOMImplementation import DOMImplementation

        try:
            s = self.doc.select(selectors)
        except:
            return None

        if s and s[0]:
            return DOMImplementation.createHTMLElement(self, s[0])

        return None
开发者ID:Gr3yR0n1n,项目名称:thug,代码行数:14,代码来源:Document.py

示例5: _querySelector

# 需要导入模块: from DOMImplementation import DOMImplementation [as 别名]
# 或者: from DOMImplementation.DOMImplementation import createHTMLElement [as 别名]
    def _querySelector(self, selectors):
        from DOMImplementation import DOMImplementation

        try:
            s = self.tag.select(selectors)
        except: #pylint:disable=bare-except
            return None

        if s and s[0]:
            return DOMImplementation.createHTMLElement(self, s[0])

        return None
开发者ID:avineshwar,项目名称:thug,代码行数:14,代码来源:DocumentFragment.py

示例6: createElement

# 需要导入模块: from DOMImplementation import DOMImplementation [as 别名]
# 或者: from DOMImplementation.DOMImplementation import createHTMLElement [as 别名]
    def createElement(self, tagname, tagvalue = None):
        from DOMImplementation import DOMImplementation

        # Internet Explorer 8 and below also support the syntax
        # document.createElement('<P>')
        if log.ThugOpts.Personality.isIE() and log.ThugOpts.Personality.browserVersion < '9.0':
            if tagname.startswith('<') and '>' in tagname:
                tagname = tagname[1:].split('>')[0]

        element = DOMImplementation.createHTMLElement(self, BeautifulSoup.Tag(parser = self.doc, name = tagname))
        if self.onCreateElement:
            self.onCreateElement(element)
        
        return element
开发者ID:Prithvirajbilla,项目名称:thug,代码行数:16,代码来源:Document.py

示例7: getter

# 需要导入模块: from DOMImplementation import DOMImplementation [as 别名]
# 或者: from DOMImplementation.DOMImplementation import createHTMLElement [as 别名]
    def getter(self):
        children = getChildren(self.doc, parts)

        if xpath == '/html/body[1]' and not children:
            children = [self.doc]

        if parts[-1] == 'text()':
            return "".join(children)

        m = RE_INDEXED.match(parts[-1])

        if m:
            try:
                from DOMImplementation import DOMImplementation
                string.atoi(m.group(2))

                return DOMImplementation.createHTMLElement(self.doc, children[0]) if len(children) > 0 else None
            except ValueError: 
                pass
                
        return HTMLCollection(self.doc, children)
开发者ID:Hanan-Natan,项目名称:thug,代码行数:23,代码来源:xpath_property.py

示例8: _getElementById

# 需要导入模块: from DOMImplementation import DOMImplementation [as 别名]
# 或者: from DOMImplementation.DOMImplementation import createHTMLElement [as 别名]
    def _getElementById(self, elementId):
        from DOMImplementation import DOMImplementation

        tag = self.doc.find(id = elementId)
        return DOMImplementation.createHTMLElement(self, tag) if tag else None
开发者ID:Prithvirajbilla,项目名称:thug,代码行数:7,代码来源:Document.py

示例9: item

# 需要导入模块: from DOMImplementation import DOMImplementation [as 别名]
# 或者: from DOMImplementation.DOMImplementation import createHTMLElement [as 别名]
    def item(self, index):
        from DOMImplementation import DOMImplementation

        node = self.nodes[index]

        return DOMImplementation.createHTMLElement(self.doc, node) if node else None
开发者ID:Debug-Orz,项目名称:thug,代码行数:8,代码来源:HTMLCollection.py

示例10: item

# 需要导入模块: from DOMImplementation import DOMImplementation [as 别名]
# 或者: from DOMImplementation.DOMImplementation import createHTMLElement [as 别名]
 def item(self, index):
     from DOMImplementation import DOMImplementation
     return DOMImplementation.createHTMLElement(self.doc, self.nodes[index]) if 0 <= index and index < len(self.nodes) else None
开发者ID:Aki92,项目名称:thug,代码行数:5,代码来源:NodeList.py


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