我正在用 Scrapy 制作一个爬虫,并想知道为什么我的 xpath 在我的 CSS 选择器运行时不起作用?我想从此 html 中获取提交的数量:
<li class="commits">
<a data-pjax="" href="/samthomson/flot/commits/master">
<span class="octicon octicon-history"></span>
<span class="num text-emphasized">
521
</span>
commits
</a>
</li
Xpath:
response.xpath('//li[@class="commits"]//a//span[@class="text-emphasized"]//text()').extract()
CSS:
response.css('li.commits a span.text-emphasized').css('::text').extract()
CSS 返回数字(未转义),但 XPath 不返回任何内容。我是否正确使用 // 嵌套元素?