MCPcopy Create free account
hub / github.com/gawel/pyquery / contents

Method contents

pyquery/pyquery.py:578–590  ·  view source on GitHub ↗

Return contents (with text nodes): >>> d = PyQuery('hello bold ') >>> d.contents() # doctest: +ELLIPSIS ['hello ', ]

(self)

Source from the content-addressed store, hash-verified

576 return self._copy(result, parent=self)
577
578 def contents(self):
579 """
580 Return contents (with text nodes):
581
582 >>> d = PyQuery('hello <b>bold</b>')
583 >>> d.contents() # doctest: +ELLIPSIS
584 ['hello ', <Element b at ...>]
585 """
586 results = []
587 for elem in self:
588 results.extend(elem.xpath('child::text()|child::*',
589 namespaces=self.namespaces))
590 return self._copy(results, parent=self)
591
592 def filter(self, selector):
593 """Filter elements in self using selector (string or function):

Callers

nothing calls this directly

Calls 2

_copyMethod · 0.95
extendMethod · 0.80

Tested by

no test coverage detected