Skip to content Skip to sidebar Skip to footer

Scrapy Xpath Utf-8 Literals

I need to check scraped fields which contain non-ascii characters. When I include a utf-8 literal in the spider, I get this error: ValueError: All strings must be XML compatible: U

Solution 1:

"//*[contains(.,u'café')]"

u'' string literals are Python syntax, not part of XPath. Try:

u"//*[contains(.,'café')]"

Post a Comment for "Scrapy Xpath Utf-8 Literals"