From f0723ab486f5b67edd02c593b10bb2f6ca4d7a3a Mon Sep 17 00:00:00 2001 From: Tamara Robichet Date: Tue, 26 Jun 2018 09:58:17 +0200 Subject: [PATCH] Add stephane plaza scraper --- scraper/src/source/stephane.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 scraper/src/source/stephane.ts diff --git a/scraper/src/source/stephane.ts b/scraper/src/source/stephane.ts new file mode 100644 index 00000000..158075ed --- /dev/null +++ b/scraper/src/source/stephane.ts @@ -0,0 +1,29 @@ +import { HTMLSource } from '../types/source' + +export default class Stephane extends HTMLSource { + public url = 'http://www.stephaneplazaimmobilier-nantesest.com/catalog/result_carto.php?action=update_search&map_polygone=&C_28=Vente&C_28_search=EGAL&C_28_type=UNIQUE&site-agence=&C_65_search=CONTIENT&C_65_type=TEXT&C_65=44+NANTES&C_65_temp=44+NANTES&cfamille_id=&C_33_search=COMPRIS&C_33_type=TEXT&C_33_MIN=&C_33_MAX=&C_30_search=INFERIEUR&C_30_type=NUMBER&C_30=&C_30_format_quick=' + public resultSelector = '[data-product-id]' + + public resultAttributes = [ + { type: 'name', selector: '.item-products_pieces' }, + { type: 'description', selector: '.item-products_address' }, + { type: 'price', selector: '.item-products_price' }, + { type: 'size', selector: '.item-products_pieces' }, + { + type: 'photo', + selector: '.slides-image.webresize', + format($: CheerioStatic, photo: CheerioElement) { + const style = $(photo).attr('style') + let imageUrl = /(background-image: url\(")(.*)("\))/gm.exec(style)[2] + imageUrl = imageUrl.split('../')[1] + return `http://www.stephaneplazaimmobilier-nantesest.com/${imageUrl}` + } + }, + { + type: 'link', + format($: CheerioStatic, link: CheerioElement): string { + return `http://www.stephaneplazaimmobilier-nantesest.com${$(link).data('url')}` + } + } + ] +}