Я triyng, чтобы построить скребок с Scapy. Я не понимаю, почему Scrapy не хочет перейти на следующую страницу. Я хочу извлечь ссылку из области разбивки на страницы ... но, увы. Мое правило для извлечения URL-адресов для перехода к следующей страницеКак добраться до следующей страницы?
Rule(LinkExtractor(restrict_xpaths='/html/body/div[19]/div[5]/div[2]/div[5]/div/div[3]/ul',allow=('page=[0-9]*')), follow=True)
Гусеничный
Class DmozSpider(CrawlSpider):
name = "arbal"
allowed_domains = ["bigbasket.com"]
start_urls = [
"http://bigbasket.com/pc/bread-dairy-eggs/bread-bakery/?nc=cs"
]
rules = (
Rule(LinkExtractor(restrict_xpaths='/html/body/div[19]/div[4]/ul',allow=('pc\/.*.\?nc=cs')), follow=True),
Rule(LinkExtractor(restrict_xpaths='/html/body/div[19]/div[5]/div[2]/div[5]/div/div[3]/ul',allow=('page=[0-9]*')), follow=True),
Rule(LinkExtractor(restrict_xpaths='//*[@id="products-container"]',allow=('pd\/*.+')), callback='parse_item', follow=True)
)
def parse_item(self, response):
item = AlabaItem()
hxs = HtmlXPathSelector(response)
item['brand_name'] = hxs.select('.//*[contains(@id, "slidingProduct")]/div[2]/div[1]/a/text()').extract()
item['prod_name'] = hxs.select('//*[contains(@id, "slidingProduct")]/div[2]/div[2]/h1/text()').extract()
yield item
кажется, что сканирование не хочет идти на следующий url beacause, получая относительный url. –