How to use the cssselect.parser.SelectorSyntaxError function in cssselect

To help you get started, we’ve selected a few cssselect examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github scrapy / parsel / tests / test_selector_csstranslator.py View on Github external
def test_attr_function_exception(self):
        cases = [
            ('::attr(12)', ExpressionError),
            ('::attr(34test)', ExpressionError),
            ('::attr(@href)', SelectorSyntaxError),
        ]
        for css, exc in cases:
            self.assertRaises(exc, self.c2x, css)
github scrapy / scrapy / tests / test_selector_csstranslator.py View on Github external
def test_attr_function_exception(self):
        cases = [
            ('::attr(12)', ExpressionError),
            ('::attr(34test)', ExpressionError),
            ('::attr(@href)', SelectorSyntaxError),
        ]
        for css, exc in cases:
            self.assertRaises(exc, self.c2x, css)
github mdn / kuma / kuma / wiki / templatetags / jinja_helpers.py View on Github external
def selector_content_find(document, selector):
    """
    Provided a selector, returns the relevant content from the document
    """
    content = ''
    try:
        page = pq(document.rendered_html)
    except ValueError:
        # pass errors during construction
        pass
    try:
        content = page.find(selector).text()
    except SelectorSyntaxError:
        # pass errors during find/select
        pass
    return content