Advertisement
Guest User

Untitled

a guest
Jan 20th, 2021
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.15 KB | None | 0 0
  1. class StarcytigamesSpider(scrapy.Spider):
  2.     name = 'starcitygames'
  3.  
  4.     def parse(self, response):
  5.         print('crawling')
  6.         prices_item = ScgPriceItem()
  7.         print(response.text)
  8.         selector = Selector(text=response.text)
  9.         prices = []
  10.         for card_item in selector.xpath('//div[@class="hawk-results-item"]'):
  11.             card_set = card_item.xpath('.//p[@class="hawk-results-item__category"]//a/text()').get()
  12.             card_info = []
  13.             for card_box in card_item.xpath('.//div[@class="hawk-results-item__options-table-row"]'):
  14.                 condition = card_box.xpath('.//div[@class="hawk-results-item__options-table-cell hawk-results-item__options-table-cell--name childCondition"]/text()').get().strip()[:-2]
  15.                 if condition != '':
  16.                     price = card_box.xpath('.//div[@class="hawk-results-item__options-table-cell hawk-results-item__options-table-cell--price childAttributes"]/text()').get().strip()
  17.                     if price != '':
  18.                         card_info.append({condition:price})
  19.             prices.append({card_set:card_info})
  20.         print(prices)
  21.         return prices
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement