如何使用Xpath在Scrapy中刮取单个容器的多个标记?

2024-09-29 17:09:33 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用Xpath在网站中刮取数据:

response.xpath('//*[@class="attr category hide--mobile"]/span/a/text()').extract()

它给出以下结果,这些结果是网站中帖子的标签

['Furniture',
 'Wardrobes',
 'Furniture',
 'Wardrobes',
 'Furniture',
 'Wardrobes',
 'Furniture',
 'Wardrobes',
 'Furniture',
 'Wardrobes',
 'Furniture',]

问题是前两个值是网站上同一容器的标记

该网站在单个容器中包含以下数据:

White and Grey Galley Walk-in Closet PLYJ17017-057
White and Grey Galley Walk-in Closet PLYJ17017-057 Specification: Code: PLYJ17017-057 Style: Modern Door: Lacquer Carcase: Melamine White and Grey Galley Walk-in Wardrobe Closet, an important part of the design for the bedroom is the addition of a...
Category: Furniture | Wardrobes

如何将家具和衣柜作为单个容器的一个整体捕获两个标签


Tags: andthe数据in网站标签容器grey

热门问题