报错信息:
Traceback (most recent call last):
File “c:\Users\86130\Desktop\Study\python\spider_learning\hello_spider.py”, line 6, in
text = ht.xpath(xpath)
File “src\lxml\etree.pyx”, line 1583, in lxml.etree._Element.xpath
File “src\lxml\xpath.pxi”, line 305, in lxml.etree.XPathElementEvaluator.call
File “src\lxml\xpath.pxi”, line 225, in lxml.etree._XPathEvaluatorBase._handle_result
lxml.etree.XPathEvalError: Invalid expression
源代码:
import lxml.html,requests
url = 'https://www.python.org/dev/peps/pep-0020/'
xpath = '//*[@id="the-zen-of-python"]/pre/text(&#x