The `:contains()` selector is completely broken

Remigiusz Modrzejewski avatarRemigiusz Modrzejewski created an issue

Today I tried to use an old script that used to work. Unfortunately, it breaks at any usage of the `:contains()` selector. A minified example:

import pyquery query = pyquery.PyQuery('<html><p>foo</p></html>') query('p:contains("foo")')

--------------------------------------------------------------------------- XPathEvalError Traceback (most recent call last) <ipython-input-5-322269d1cc1f> in <module>() ----> 1 query('p:contains("foo")')

/usr/local/Cellar/python/2.7.3/lib/python2.7/site-packages/pyquery/pyquery.pyc in call(self, *args, kwargs) 245 not args[0].startswith('<'): 246 args += (self,) --> 247 result = self.class(*args, parent=self, kwargs) 248 return result 249

/usr/local/Cellar/python/2.7.3/lib/python2.7/site-packages/pyquery/pyquery.pyc in init(self, *args, kwargs) 221 xpath = self._css_to_xpath(selector) 222 results = [tag.xpath(xpath, namespaces=namespaces) \ --> 223 for tag in elements] 224 # Flatten the results 225 elements = []

/usr/local/Cellar/python/2.7.3/lib/python2.7/site-packages/lxml/ in lxml.etree._Element.xpath (src/lxml/lxml.etree.c:45370)()

/usr/local/Cellar/python/2.7.3/lib/python2.7/site-packages/lxml/ in (src/lxml/lxml.etree.c:125700)()

/usr/local/Cellar/python/2.7.3/lib/python2.7/site-packages/lxml/ in lxml.etree._XPathEvaluatorBase._handle_result (src/lxml/lxml.etree.c:124824)()

/usr/local/Cellar/python/2.7.3/lib/python2.7/site-packages/lxml/ in lxml.etree._XPathEvaluatorBase._raise_eval_error (src/lxml/lxml.etree.c:124693)()

XPathEvalError: Invalid expression

Comments (1)

  1. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.