[英]SCRAPY not printing all the items in the terminal
I am using this command in the terminal using SCRAPY Shell but it's not printing all the items.我在终端中使用 SCRAPY Shell 使用此命令,但它没有打印所有项目。
scrapy shell https://access.redhat.com/errata/RHSA-2017:0621
response.xpath('normalize-space((//div[contains(@class, "tab-pane")]/ul)[2]/li/text())').getall()
It just prints the first item.它只打印第一项。
normalize-space()
only works with a single node. normalize-space()
仅适用于单个节点。 If you give it a nodeset, it will return the value produced from the first node.如果给它一个节点集,它将返回从第一个节点产生的值。
If you want to apply it to multiple nodes, you can do that as follows ( pp
is just a pretty-printing function):如果你想将它应用到多个节点,你可以这样做(
pp
只是一个漂亮的打印功能):
>>> products = response.xpath('(//div[contains(@class, "tab-pane")]/ul)[2]/li').xpath('normalize-space()').getall()
>>> pp(products)
[
'Red Hat Enterprise Linux Server 6 x86_64',
'Red Hat Enterprise Linux Server 6 i386',
'Red Hat Enterprise Linux Workstation 6 x86_64',
'Red Hat Enterprise Linux Workstation 6 i386',
'Red Hat Enterprise Linux Desktop 6 x86_64',
'Red Hat Enterprise Linux Desktop 6 i386',
'Red Hat Enterprise Linux for Power, big endian 6 ppc64',
'Red Hat Enterprise Linux for Scientific Computing 6 x86_64'
]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.