MV
не получается в CrawlSpider =(
рул почему-то не отрабатывает. могу код сбросить
Size: a a a
MV
MV
# -*- coding: utf-8 -*-
import scrapy
from scrapy.spiders import CrawlSpider, Rule
from scrapy.linkextractors import LinkExtractor
class SmartphoneSpiderSpider(CrawlSpider):
name = 'smartphone_spider'
allowed_domains = ['hotline.ua']
start_urls = ['https://hotline.ua/mobile/mobilnye-telefony-i-smartfony/']
rules = (
Rule(LinkExtractor(restrict_xpaths='//li[@class="product-item"]/div[@class="item-info"]/p[@class="h4"]/a'), callback='parse_item', follow=True),
)
def parse_item(self, response):
print('---')
card_title = response.css('.card-title::text').get()
yield { card_title }
def parse(self, response):
pass
# product_items = response.css('.product-item .item-info a::attr(href)').getall()
# for product in product_items:
# yield { product: product }
# next_page = int(response.css('.pages.active::text').get()) + 1
# last_page= int(response.css('a.pages::text').getall()[-1])
# print('!!!!!', next_page)
# print('!!!!!', last_page)
# if next_page <= last_page:
# absolute_next_page_url = response.urljoin('?p=' + str(next_page))
# yield scrapy.Request(absolute_next_page_url)
MV
MV
s
MV
parse метода =)s
parse метода =)MV
s
MV
s
MV
MV
К
К
MV
s
Y