问答详情
源自:2-7 spider文件的编写(2)

运行main.py后出现如下错误是怎么回事呢

我刚安装的python跟scrapy,按视频操作后出现一堆log(log就不列出了),跟如下错误信息,不知道是怎么回事呢


During handling of the above exception, another exception occurred:


Traceback (most recent call last):

  File "/usr/local/lib/python3.7/site-packages/twisted/internet/defer.py", line 654, in _runCallbacks

    current.result = callback(current.result, *args, **kw)

  File "/Users/Ca/douban/douban/spiders/douban_spider.py", line 18, in parse

    douban_item['serial_number'] = i_item.xpath(".//div[@class=item']//em/text()").extract_first()

  File "/usr/local/lib/python3.7/site-packages/parsel/selector.py", line 242, in xpath

    six.reraise(ValueError, ValueError(msg), sys.exc_info()[2])

  File "/usr/local/lib/python3.7/site-packages/six.py", line 692, in reraise

    raise value.with_traceback(tb)

  File "/usr/local/lib/python3.7/site-packages/parsel/selector.py", line 238, in xpath

    **kwargs)

  File "src/lxml/etree.pyx", line 1577, in lxml.etree._Element.xpath

  File "src/lxml/xpath.pxi", line 307, in lxml.etree.XPathElementEvaluator.__call__

  File "src/lxml/xpath.pxi", line 227, in lxml.etree._XPathEvaluatorBase._handle_result

ValueError: XPath error: Invalid predicate in .//div[@class=item']//em/text()


提问者:慕瓜4233649 2018-08-09 21:31

个回答

  • qq_客欲远行_0
    2018-08-10 11:55:14

    18行代码,单引号