Demo entry 6634007

Python

   

Submitted by anonymous on Aug 08, 2017 at 13:22
Language: Python 3. Code size: 1.4 kB.

#import pakietu
from selenium import webdriver
import scrapy

#definicja adresu strony internetowej
class MySpider(scrapy.Spider):
    name = 'massEffect'
    start_urls = ['http://www.euro.com.pl/telefony-komorkowe,g!smartfon,strona-21.bhtml']
   
#punkt startowy
    def parse(self, response):
            for href in response.css('h2.product-name a::attr(href)'):
                url = response.urljoin(href.extract())
            yield scrapy.Request(url, callback=self.parse_detail_page)
       
# przejscie do kolejnej zakładki strony        
        next_page1 = response.css('div.paging a::attr(href)').extract_first()
        if next_page1 is not None:
            next_page1 = response.urljoin(next_page1)
            yield scrapy.Request(next_page1, callback=self.parse)
           
# dane wynikowe   
          
    def parse_detail_page(self, response):
        comic = dict()
        comic['nazwa']= response.xpath('//h1[@class="selenium-product-name"]/text()').extract()
        comic['id']= response.xpath('//div[@class="opinion-nick"]/text()').extract()
        comic['ocena'] = response.xpath('//*[@class="stars-rating"]/@title').extract()
        comic['url'] = response.url
        comic['parametr']= response.xpath('//span[@class="attribute-value"]/text()').extract()
        yield comic
 
 
    
    
    
    
    

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).