예제 #1
0
    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
예제 #2
0
    def item(self, index):
        from DOMImplementation import DOMImplementation

        node = self.nodes[index]

        return DOMImplementation.createHTMLElement(self.doc,
                                                   node) if node else None
예제 #3
0
파일: Document.py 프로젝트: chorsley/thug
    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
예제 #4
0
    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
예제 #5
0
    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
예제 #6
0
파일: Element.py 프로젝트: anh2hn/thug
    def _querySelector(self, selectors):
        from DOMImplementation import DOMImplementation

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

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

        return None
예제 #7
0
    def _querySelector(self, selectors):
        from DOMImplementation import DOMImplementation

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

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

        return None
예제 #8
0
파일: Document.py 프로젝트: Gr3yR0n1n/thug
    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
예제 #9
0
    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
예제 #10
0
    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
예제 #11
0
    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)
예제 #12
0
    def createElement(self, tagname, tagvalue=None):
        # zomo
        import re
        match = re.search('iframe', str(tagname).lower())
        if match:
            log.ThugLogging.add_behavior_warn(
                "[iframe injection: createElement] %s" % str(tagname))

        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
예제 #13
0
    def _getElementById(self, elementId):
        from DOMImplementation import DOMImplementation

        tag = self.doc.find(id = elementId)
        return DOMImplementation.createHTMLElement(self, tag) if tag else None
예제 #14
0
 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
예제 #15
0
    def item(self, index):
        from DOMImplementation import DOMImplementation

        node = self.nodes[index]

        return DOMImplementation.createHTMLElement(self.doc, node) if node else None
예제 #16
0
파일: NodeList.py 프로젝트: Aki92/thug
 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
예제 #17
0
파일: w3c.py 프로젝트: medim/thug
def getDOMImplementation(dom = None, **kwds):
    return DOMImplementation(dom if dom else BeautifulSoup.BeautifulSoup(), **kwds)
예제 #18
0
파일: w3c.py 프로젝트: medim/thug
def parseString(html, **kwds):
    return DOMImplementation(BeautifulSoup.BeautifulSoup(html, "html5lib"), **kwds)
예제 #19
0
 def isSupported(self, feature, version):
     from DOMImplementation import DOMImplementation
     return DOMImplementation.hasFeature(feature, version)
예제 #20
0
파일: Node.py 프로젝트: Gr3yR0n1n/thug
 def isSupported(self, feature, version):
     from DOMImplementation import DOMImplementation
     return DOMImplementation.hasFeature(feature, version)