Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def getElementsByName(self, elementName):
from .HTMLCollection import HTMLCollection
tags = self.doc.find_all(attrs = {'name': elementName})
return HTMLCollection(self.doc, tags)
def __init__(self, doc, nodes):
HTMLCollection.__init__(self, doc, nodes)
def forms(self):
from .HTMLCollection import HTMLCollection
nodes = [f for f in self.doc.find_all('form')]
return HTMLCollection(self.doc, nodes)
def __init__(self, doc, tag):
HTMLElement.__init__(self, doc, tag)
self._rows = HTMLCollection(doc, list())
def anchors(self):
from .HTMLCollection import HTMLCollection
nodes = [f for f in self.doc.find_all('a') if 'name' in f.attrs and f.attrs['name']]
return HTMLCollection(self.doc, nodes)
def applets(self):
from .HTMLCollection import HTMLCollection
applets = [f for f in self.doc.find_all('applet')]
objects = [f for f in self.doc.find_all('object') if 'type' in f.attrs and 'applet' in f.attrs['type']]
return HTMLCollection(self.doc, applets + objects)
def __init__(self, doc, tag):
HTMLElement.__init__(self, doc, tag)
self._caption = None
self._tHead = None
self._tFoot = None
self._rows = HTMLCollection(doc, list())
self._tBodies = HTMLCollection(doc, list())
if parts[-1] == 'text()':
return "".join(children)
m = RE_INDEXED.match(parts[-1])
if m:
try:
from thug.DOM.W3C.Core.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)
#!/usr/bin/env python
from .HTMLCollection import HTMLCollection
# Introduced in DOM Level 2
class HTMLOptionsCollection(HTMLCollection):
def __init__(self, doc, nodes):
HTMLCollection.__init__(self, doc, nodes)
def frames(self):
"""an array of all the frames (including iframes) in the current window"""
from thug.DOM.W3C.HTML.HTMLCollection import HTMLCollection
frames = set()
for frame in self._findAll(['frame', 'iframe']):
if not getattr(frame, '_node', None):
from thug.DOM.W3C.Core.DOMImplementation import DOMImplementation
DOMImplementation.createHTMLElement(self.window.doc, frame)
frames.add(frame._node)
return HTMLCollection(self.doc, list(frames))