PricePerSqm Pipeline
This commit is contained in:
parent
828035e166
commit
ec7acf9308
|
@ -10,11 +10,8 @@
|
|||
|
||||
class PricePerSqmPipeline:
|
||||
def process_item(self, item, spider):
|
||||
'''
|
||||
pricefloat = float(price.replace(',', '.').replace(' ', '').replace('€', ''))
|
||||
areafloat = float(area.replace(',', '.').replace(' ', '').replace('m²', ''))
|
||||
pricesqmint = round(pricefloat / areafloat)
|
||||
pricepersqm = float(item['price']) / float(item['area'])
|
||||
item['price/sqm'] = pricepersqm
|
||||
'''
|
||||
area = item['area']
|
||||
if area is not None:
|
||||
pricepersqm = item['price'] / float(item['area'])
|
||||
item['price/sqm'] = round(pricepersqm)
|
||||
return item
|
||||
|
|
|
@ -37,10 +37,10 @@ class PAPSpider(scrapy.Spider):
|
|||
yield {
|
||||
'url': self.baseurl + url,
|
||||
'type': 'Unknown',
|
||||
'price': ad.css(self.price_css_sel).get().replace('.', '').replace('\xa0€', ''),
|
||||
'price': int(ad.css(self.price_css_sel).get().replace('.', '').replace('\xa0€', '')),
|
||||
'rooms': rooms,
|
||||
'bedrooms': bedrooms,
|
||||
'area': infos.xpath('./li[contains(small, "m")]/text()').get()
|
||||
'area': infos.xpath('./li[contains(small, "m")]/text()').get().replace(' ', '')
|
||||
}
|
||||
|
||||
next_page = response.xpath(self.next_page_xpath).get()
|
||||
|
|
|
@ -57,10 +57,10 @@ class SelogerSpider(scrapy.Spider):
|
|||
yield {
|
||||
'url': ad.css(self.url_css_sel).get().split('?')[0],
|
||||
'type': ad.css(self.type_css_sel).get().replace('/Villa', ''),
|
||||
'price': ad.css(self.price_css_sel).get().replace('\xa0', '').replace(' €', ''),
|
||||
'price': int(ad.css(self.price_css_sel).get().replace('\xa0', '').replace(' €', '')),
|
||||
'rooms': rooms,
|
||||
'bedrooms': bedrooms,
|
||||
'area': area
|
||||
'area': area.replace(',', '.')
|
||||
}
|
||||
active_page = response.url
|
||||
active_page_nb = int(active_page.split('LISTING-LISTpg=')[1])
|
||||
|
|
|
@ -87,7 +87,7 @@ class LeboncoinSpider(scrapy.Spider):
|
|||
yield {
|
||||
'url': ad['url'],
|
||||
'type': type,
|
||||
'price': ad['price'][0],
|
||||
'price': int(ad['price'][0]),
|
||||
'rooms': rooms,
|
||||
'bedrooms': 'Unknown',
|
||||
'area': area
|
||||
|
|
Loading…
Reference in New Issue