【发布时间】:2014-01-04 11:52:14
【问题描述】:
我正在运行scrapy 0.20.2。
$ scrapy shell "http://newyork.craigslist.org/ata/"
我想将所有指向广告页面的链接列表与 index.html 分开
$ sel.xpath('//a[contains(@href,html)]')
...
<Selector xpath='//a[contains(@href,"html")]' data=u'<a href="/mnh/atq/4243973984.html">Wicke'>,
<Selector xpath='//a[contains(@href,"html")]' data=u'<a href="/mnh/atd/4257230057.html" class'>,
<Selector xpath='//a[contains(@href,"html")]' data=u'<a href="/mnh/atd/4257230057.html">Recla'>,
<Selector xpath='//a[contains(@href,"html")]' data=u'<a href="/ata/index100.html" class="butt'>]
我想使用 XPath 匹配函数来匹配正则表达式 [0-9]+.html 形式的链接。
$ sel.xpath('//a[matches(@href,"[0-9]+.html")]')
...
ValueError: Invalid XPath: //a[matches(@href,"[0-9]+.html")]
怎么了?谢谢。
【问题讨论】: