Парсер должен собирать цены и выводить в консоль. Выводит только единственную цену. Если использовать метод .getall() вместо .get() в условиях, то показывает все существующие цены.
В чем проблема, что не выводит все цены?
class WildberriesSpider(scrapy.Spider):
name = 'Wildberries'
allowed_domains = ['wildberries.ru']
start_urls = ['https://www.wildberries.ru/catalog/muzhchinam/odezhda/verhnyaya-odezhda']
def parse(self, response: HtmlResponse):
for card in response.xpath('//div[@class="dtList i-dtList j-card-item "]'):
if card.xpath('//ins[@class="lower-price"]/text()') is not None:
price = card.xpath('..//ins[@class="lower-price"]/text()').get()
else:
price = card.xpath('..//span[@class="lower-price"]/text()').get()
yield {'price': price.replace('\xa0', '')}