def parse(self, response):
sel=scrapy.Selector(response)
items_list=sel.css('#main > div.containerbox.boxindex > div.layui-row.layui-col-space15 > div:nth-child(1) > table > tbody > tr')选择器来自复制->复制选择器。
我调试了代码,响应是正确的。
我在铬中使用了$$("selector"),它也是正确的
allowed_domains是正确的
但是items_list=[]
发布于 2022-06-20 07:44:59
在使用CSS选择器时,您缺少了.get()和.getall()。
如果只需要提取第一个元素,请使用.get()
items_list=sel.css('#main > div.containerbox.boxindex > div.layui-row.layui-col-space15 > div:nth-child(1) > table > tbody > tr').get()或者,如果需要提取所有元素,请使用.getall()
items_list=sel.css('#main > div.containerbox.boxindex > div.layui-row.layui-col-space15 > div:nth-child(1) > table > tbody > tr').getall()https://stackoverflow.com/questions/72639340
复制相似问题