У меня проблема со сканированием следующей кнопки. Я попробовал базовую кнопку, но после проверки HTML-кода, она использует javascript. Я попробовал другие правила, но ничего не работает, вот ссылка на сайт.
https://www2.hm.com/en_us/sale/shopbyproductladies/view-all.html
Следующее название кнопки «Загрузить другие товары»
вот мой рабочий код
def parse(self, response):
for product_item in response.css('li.product-item'):
url = "https://www2.hm.com/" + product_item.css('a::attr(href)').extract_first()
yield scrapy.Request(url=url, callback=self.parse_subpage)
def parse_subpage(self, response):
item = {
'title': response.xpath("normalize-space(.//h1[contains(@class, 'primary') and contains(@class, 'product-item-headline')]/text())").extract_first(),
'sale-price': response.xpath("normalize-space(.//span[@class='price-value']/text())").extract_first(),
'regular-price': response.xpath('//script[contains(text(), "whitePrice")]/text()').re_first("'whitePrice'\s?:\s?'([^']+)'"),
'photo-url': response.css('div.product-detail-main-image-container img::attr(src)').extract_first(),
'description': response.css('p.pdp-description-text::text').extract_first()
}
yield item