coding: utf-8
urls = urls.xpath('//img/ancestor::a[not(re:match(@href, "(слово)")) ]/@href', namespaces={"re": "http://exslt.org/regular-expressions"}) File "lxml.etree.pyx", line 1444, in lxml.etree._Element.xpath (src/lxml/lxml.etree.c:41726) File "xpath.pxi", line 308, in lxml.etree.XPathElementEvaluator.__call__ (src/lxml/lxml.etree.c:117742) File "apihelpers.pxi", line 1366, in lxml.etree._utf8 (src/lxml/lxml.etree.c:22068) ValueError: All strings must be XML compatible: Unicode or ASCII, no NULL bytes or control characters