From 69989fff0c5d18c069120081eb5cfcc6a9bf8c29 Mon Sep 17 00:00:00 2001 From: Joris Date: Mon, 9 Sep 2019 21:10:39 +0200 Subject: Update ouestfrance and seloger tests --- src/lib/haskell/Parser/LeboncoinParser.hs | 2 +- src/test/haskell/Ads.hs | 152 +- src/test/haskell/ParserSpec.hs | 69 +- src/test/resources/ouestFrance.html | 2094 +++++---- src/test/resources/seLoger.html | 6559 ++++++++++++++++------------- 5 files changed, 4792 insertions(+), 4084 deletions(-) diff --git a/src/lib/haskell/Parser/LeboncoinParser.hs b/src/lib/haskell/Parser/LeboncoinParser.hs index 99d8116..3e6775d 100644 --- a/src/lib/haskell/Parser/LeboncoinParser.hs +++ b/src/lib/haskell/Parser/LeboncoinParser.hs @@ -26,4 +26,4 @@ parseAd tags = do [] -> Nothing xs -> Just $ innerText xs url <- getTagAttribute "" "href" tags - return (Ad name location price (T.concat ["https:", url])) + return (Ad name location price (T.concat ["https://www.leboncoin.fr", url])) diff --git a/src/test/haskell/Ads.hs b/src/test/haskell/Ads.hs index fc934e1..d63c1ab 100644 --- a/src/test/haskell/Ads.hs +++ b/src/test/haskell/Ads.hs @@ -8,93 +8,83 @@ import Model.Ad (Ad (..)) leboncoin :: [Ad] leboncoin = - [ Ad {name = "Appartement libre de suite", location = "Meaux 77100", price = Just "870 €", url = "https:/locations/1666147031.htm/"} - , Ad {name = "Appartement 2 pièces aux Clayes sous Bois", location = "Les Clayes-sous-Bois 78340", price = Just "790 €", url = "https:/locations/1669740131.htm/"} - , Ad {name = "APPARTEMENT T2 - 33 m\178 - MONTROUGE (92)", location = "Montrouge 92120", price = Just "960 €", url = "https:/locations/1669731506.htm/"} - , Ad {name = "2 chambres à louer / Sèvres (92) proche Paris", location = "Sèvres 92310", price = Just "490 €", url = "https:/locations/1665328647.htm/"} - , Ad {name = "Location Appartement Montreuil", location = "Montreuil 93100", price = Just "970 €", url = "https:/locations/1669739489.htm/"} - , Ad {name = "Chambre pour étudiante dans appartement Cergy préf", location = "Cergy 95000", price = Just "480 €", url = "https:/locations/1669738832.htm/"} - , Ad {name = "Transporteur déménagement", location = "Paris 75019", price = Just "1 €", url = "https:/locations/1669738226.htm/"} - , Ad {name = "Loue appartement", location = "Condécourt 95450", price = Just "750 €", url = "https:/locations/1669737696.htm/"} - , Ad {name = "Place de parking VERSAILLES RIVE DROITE", location = "Versailles 78000", price = Just "70 €", url = "https:/locations/1669737014.htm/"} - , Ad {name = "Recherche chambre à louer", location = "Lognes 77185", price = Just "300 €", url = "https:/locations/1669737144.htm/"} - , Ad {name = "Appartement 2 pièce splendide 36m2 Paris 13", location = "Paris 75013", price = Just "910 €", url = "https:/locations/1669616026.htm/"} - , Ad {name = "Place de parking sécurisée", location = "Issy-les-Moulineaux 92130", price = Just "100 €", url = "https:/locations/1666255917.htm/"} - , Ad {name = "2 pièces 35m2 meublé 800 Euro(s) CC 8 mois max", location = "Argenteuil 95100", price = Just "800 €", url = "https:/locations/1669735875.htm/"} - , Ad {name = "Parking à louer rue st maur", location = "Paris 75011", price = Just "108 €", url = "https:/locations/1657100196.htm/"} - , Ad {name = "Box 13m2 securisé", location = "Bagnolet 93170", price = Just "95 €", url = "https:/locations/1669735007.htm/"} - , Ad {name = "Chambre en rez de chaussée", location = "Maisons-Laffitte 78600", price = Just "425 €", url = "https:/locations/1669734792.htm/"} - , Ad {name = "A louer maison f4", location = "Champagne-sur-Oise 95660", price = Just "1 350 €", url = "https:/locations/1669734636.htm/"} - , Ad {name = "2 pièces à Paris 20ème 36m2 Libre de suite", location = "Paris 75020", price = Just "950 €", url = "https:/locations/1669240126.htm/"} - , Ad {name = "Loue box garage", location = "Les Clayes-sous-Bois 78340", price = Just "130 €", url = "https:/locations/1669733972.htm/"} - , Ad {name = "Mets en sous location F2 dans le récents", location = "Créteil 94000", price = Just "980 €", url = "https:/locations/1669733841.htm/"} - , Ad {name = "Parking à 5mn de l'aéroport chez particulier", location = "Orly 94310", price = Just "5 €", url = "https:/locations/1669733667.htm/"} - , Ad {name = "2 pieces gare de l est", location = "Paris 75010", price = Just "1 015 €", url = "https:/locations/1669619541.htm/"} - , Ad {name = "Chambre meublée pr étudiant saison univ2019-2020", location = "Saint-Ouen-l'Aumône 95310", price = Just "430 €", url = "https:/locations/1669730619.htm/"} - , Ad {name = "Location studio à Levallois", location = "Levallois-Perret 92300", price = Just "700 €", url = "https:/locations/1669729351.htm/"} - , Ad {name = "Coloc à 3 val de fontenay recherche femme", location = "Fontenay-sous-Bois 94120", price = Just "500 €", url = "https:/locations/1669729707.htm/"} - , Ad {name = "Cave cimenté et seche dans résidence récente", location = "Pantin 93500", price = Just "70 €", url = "https:/locations/1669729874.htm/"} - , Ad {name = "bel appartement lumineux avec jardin", location = "Corbeil-Essonnes 91100", price = Just "850 €", url = "https:/locations/1669729645.htm/"} - , Ad {name = "Pavillon", location = "Igny 91430", price = Just "1 500 €", url = "https:/locations/1669627532.htm/"} - , Ad {name = "Parking à louer rue de Tocqueville 75017", location = "Paris 75017", price = Just "170 €", url = "https:/locations/1669728766.htm/"} - , Ad {name = "Studio duplex", location = "Montlhéry 91310", price = Just "660 €", url = "https:/locations/1669728747.htm/"} - , Ad {name = "Appartement F2 à Bois D'Arcy", location = "Bois-d'Arcy 78390", price = Just "730 €", url = "https:/locations/1669728345.htm/"} - , Ad {name = "maison 2 pièces 50 m2", location = "Epinay-sur-Seine 93800", price = Just "800 €", url = "https:/locations/1669728424.htm/"} - , Ad {name = "Appartement 3 pièces 80m\178", location = "Brunoy 91800", price = Just "1 242 €", url = "https:/locations/1639808089.htm/"} - , Ad {name = "Location appartement refait à neuf proche Paris", location = "Montreuil 93100", price = Just "900 €", url = "https:/locations/1669727321.htm/"} - , Ad {name = "Location Studio Photo Video", location = "Ivry-sur-Seine 94200", price = Just "350 €", url = "https:/locations/1669727197.htm/"} - , Ad {name = "Maison avec jardinet", location = "Champagne-sur-Seine 77430", price = Nothing, url = "https:/locations/1667510230.htm/"} - , Ad {name = "Parking proche Place Gambetta Paris 20", location = "Paris 75020", price = Nothing, url = "https:/locations/1640071173.htm/"} - , Ad {name = "Appt 80m2.3/4 pièces.75013 limite 75005", location = "Paris 75005", price = Nothing, url = "https:/locations/1665224562.htm/"} + [ Ad {name = "Appartement libre de suite", location = "Meaux 77100", price = Just "870 €", url = "https://www.leboncoin.fr/locations/1666147031.htm/"} + , Ad {name = "Appartement 2 pièces aux Clayes sous Bois", location = "Les Clayes-sous-Bois 78340", price = Just "790 €", url = "https://www.leboncoin.fr/locations/1669740131.htm/"} + , Ad {name = "APPARTEMENT T2 - 33 m\178 - MONTROUGE (92)", location = "Montrouge 92120", price = Just "960 €", url = "https://www.leboncoin.fr/locations/1669731506.htm/"} + , Ad {name = "2 chambres à louer / Sèvres (92) proche Paris", location = "Sèvres 92310", price = Just "490 €", url = "https://www.leboncoin.fr/locations/1665328647.htm/"} + , Ad {name = "Location Appartement Montreuil", location = "Montreuil 93100", price = Just "970 €", url = "https://www.leboncoin.fr/locations/1669739489.htm/"} + , Ad {name = "Chambre pour étudiante dans appartement Cergy préf", location = "Cergy 95000", price = Just "480 €", url = "https://www.leboncoin.fr/locations/1669738832.htm/"} + , Ad {name = "Transporteur déménagement", location = "Paris 75019", price = Just "1 €", url = "https://www.leboncoin.fr/locations/1669738226.htm/"} + , Ad {name = "Loue appartement", location = "Condécourt 95450", price = Just "750 €", url = "https://www.leboncoin.fr/locations/1669737696.htm/"} + , Ad {name = "Place de parking VERSAILLES RIVE DROITE", location = "Versailles 78000", price = Just "70 €", url = "https://www.leboncoin.fr/locations/1669737014.htm/"} + , Ad {name = "Recherche chambre à louer", location = "Lognes 77185", price = Just "300 €", url = "https://www.leboncoin.fr/locations/1669737144.htm/"} + , Ad {name = "Appartement 2 pièce splendide 36m2 Paris 13", location = "Paris 75013", price = Just "910 €", url = "https://www.leboncoin.fr/locations/1669616026.htm/"} + , Ad {name = "Place de parking sécurisée", location = "Issy-les-Moulineaux 92130", price = Just "100 €", url = "https://www.leboncoin.fr/locations/1666255917.htm/"} + , Ad {name = "2 pièces 35m2 meublé 800 Euro(s) CC 8 mois max", location = "Argenteuil 95100", price = Just "800 €", url = "https://www.leboncoin.fr/locations/1669735875.htm/"} + , Ad {name = "Parking à louer rue st maur", location = "Paris 75011", price = Just "108 €", url = "https://www.leboncoin.fr/locations/1657100196.htm/"} + , Ad {name = "Box 13m2 securisé", location = "Bagnolet 93170", price = Just "95 €", url = "https://www.leboncoin.fr/locations/1669735007.htm/"} + , Ad {name = "Chambre en rez de chaussée", location = "Maisons-Laffitte 78600", price = Just "425 €", url = "https://www.leboncoin.fr/locations/1669734792.htm/"} + , Ad {name = "A louer maison f4", location = "Champagne-sur-Oise 95660", price = Just "1 350 €", url = "https://www.leboncoin.fr/locations/1669734636.htm/"} + , Ad {name = "2 pièces à Paris 20ème 36m2 Libre de suite", location = "Paris 75020", price = Just "950 €", url = "https://www.leboncoin.fr/locations/1669240126.htm/"} + , Ad {name = "Loue box garage", location = "Les Clayes-sous-Bois 78340", price = Just "130 €", url = "https://www.leboncoin.fr/locations/1669733972.htm/"} + , Ad {name = "Mets en sous location F2 dans le récents", location = "Créteil 94000", price = Just "980 €", url = "https://www.leboncoin.fr/locations/1669733841.htm/"} + , Ad {name = "Parking à 5mn de l'aéroport chez particulier", location = "Orly 94310", price = Just "5 €", url = "https://www.leboncoin.fr/locations/1669733667.htm/"} + , Ad {name = "2 pieces gare de l est", location = "Paris 75010", price = Just "1 015 €", url = "https://www.leboncoin.fr/locations/1669619541.htm/"} + , Ad {name = "Chambre meublée pr étudiant saison univ2019-2020", location = "Saint-Ouen-l'Aumône 95310", price = Just "430 €", url = "https://www.leboncoin.fr/locations/1669730619.htm/"} + , Ad {name = "Location studio à Levallois", location = "Levallois-Perret 92300", price = Just "700 €", url = "https://www.leboncoin.fr/locations/1669729351.htm/"} + , Ad {name = "Coloc à 3 val de fontenay recherche femme", location = "Fontenay-sous-Bois 94120", price = Just "500 €", url = "https://www.leboncoin.fr/locations/1669729707.htm/"} + , Ad {name = "Cave cimenté et seche dans résidence récente", location = "Pantin 93500", price = Just "70 €", url = "https://www.leboncoin.fr/locations/1669729874.htm/"} + , Ad {name = "bel appartement lumineux avec jardin", location = "Corbeil-Essonnes 91100", price = Just "850 €", url = "https://www.leboncoin.fr/locations/1669729645.htm/"} + , Ad {name = "Pavillon", location = "Igny 91430", price = Just "1 500 €", url = "https://www.leboncoin.fr/locations/1669627532.htm/"} + , Ad {name = "Parking à louer rue de Tocqueville 75017", location = "Paris 75017", price = Just "170 €", url = "https://www.leboncoin.fr/locations/1669728766.htm/"} + , Ad {name = "Studio duplex", location = "Montlhéry 91310", price = Just "660 €", url = "https://www.leboncoin.fr/locations/1669728747.htm/"} + , Ad {name = "Appartement F2 à Bois D'Arcy", location = "Bois-d'Arcy 78390", price = Just "730 €", url = "https://www.leboncoin.fr/locations/1669728345.htm/"} + , Ad {name = "maison 2 pièces 50 m2", location = "Epinay-sur-Seine 93800", price = Just "800 €", url = "https://www.leboncoin.fr/locations/1669728424.htm/"} + , Ad {name = "Appartement 3 pièces 80m\178", location = "Brunoy 91800", price = Just "1 242 €", url = "https://www.leboncoin.fr/locations/1639808089.htm/"} + , Ad {name = "Location appartement refait à neuf proche Paris", location = "Montreuil 93100", price = Just "900 €", url = "https://www.leboncoin.fr/locations/1669727321.htm/"} + , Ad {name = "Location Studio Photo Video", location = "Ivry-sur-Seine 94200", price = Just "350 €", url = "https://www.leboncoin.fr/locations/1669727197.htm/"} + , Ad {name = "Maison avec jardinet", location = "Champagne-sur-Seine 77430", price = Nothing, url = "https://www.leboncoin.fr/locations/1667510230.htm/"} + , Ad {name = "Parking proche Place Gambetta Paris 20", location = "Paris 75020", price = Nothing, url = "https://www.leboncoin.fr/locations/1640071173.htm/"} + , Ad {name = "Appt 80m2.3/4 pièces.75013 limite 75005", location = "Paris 75005", price = Nothing, url = "https://www.leboncoin.fr/locations/1665224562.htm/"} ] ouestFrance :: [Ad] ouestFrance = - [ Ad {name = "Maison 3 chambres", location = "Rennes", price = Just "210 €", url = "https://www.ouestfrance-immo.com//immobilier/location/maison/rennes-35-35238/13108048.htm"} - , Ad {name = "Maison 4 chambres", location = "Rennes Sacré Coeurs", price = Just "1 094 €", url = "https://www.ouestfrance-immo.com//immobilier/location/maison/rennes-35-35238/13114249.htm"} - , Ad {name = "Maison 1 pièce", location = "Rennes Bourg L'evêque", price = Just "370 €", url = "https://www.ouestfrance-immo.com//immobilier/location/maison/rennes-35-35238/13113524.htm"} - , Ad {name = "Maison 2 chambres", location = "Rennes Sainte-Thérèse", price = Just "869 €", url = "https://www.ouestfrance-immo.com//immobilier/location/maison/rennes-35-35238/13111302.htm"} - , Ad {name = "Maison 4 chambres", location = "Rennes Nord Saint-Martin", price = Just "1 650 €", url = "https://www.ouestfrance-immo.com//immobilier/location/maison/rennes-35-35238/13109610.htm"} - , Ad {name = "Maison 2 chambres", location = "Rennes Sainte-Thérèse", price = Just "915 €", url = "https://www.ouestfrance-immo.com//immobilier/location/maison/rennes-35-35238/13020322.htm"} - , Ad {name = "Maison 4 chambres", location = "Rennes Brequigny", price = Just "1 011 €", url = "https://www.ouestfrance-immo.com//immobilier/location/maison/rennes-35-35238/13107308.htm"} - , Ad {name = "Maison 6 chambres", location = "Rennes Jeanne D'arc", price = Just "2 715 €", url = "https://www.ouestfrance-immo.com//immobilier/location/maison/rennes-35-35238/13104531.htm"} - , Ad {name = "Maison 3 chambres", location = "Rennes", price = Just "1 025 €", url = "https://www.ouestfrance-immo.com//immobilier/location/maison/rennes-35-35238/13104556.htm"} - , Ad {name = "Maison 4 chambres", location = "Rennes Patton", price = Just "1 270 €", url = "https://www.ouestfrance-immo.com//immobilier/location/maison/rennes-35-35238/12742357.htm"} - , Ad {name = "Maison 4 chambres", location = "Rennes Jeanne D'arc", price = Just "1 616 €", url = "https://www.ouestfrance-immo.com//immobilier/location/maison/rennes-35-35238/12938970.htm"} - , Ad {name = "Maison 4 chambres", location = "Rennes Sainte-Thérèse", price = Just "1 910 €", url = "https://www.ouestfrance-immo.com//immobilier/location/maison/rennes-35-35238/13050770.htm"} - , Ad {name = "Maison 7 chambres", location = "Rennes Centre Ville", price = Just "3 000 €", url = "https://www.ouestfrance-immo.com//immobilier/location/maison/rennes-35-35238/12888774.htm"} - , Ad {name = "Maison 5 chambres", location = "Rennes Patton", price = Just "1 500 €", url = "https://www.ouestfrance-immo.com//immobilier/location/maison/rennes-35-35238/12317304.htm"} - , Ad {name = "Maison 6 chambres", location = "Rennes Sainte-Thérèse", price = Just "1 850 €", url = "https://www.ouestfrance-immo.com//immobilier/location/maison/rennes-35-35238/12874271.htm"} - , Ad {name = "Maison 4 chambres", location = "Rennes Sud", price = Just "895 €", url = "https://www.ouestfrance-immo.com//immobilier/location/maison/rennes-35-35238/11139843.htm"} - , Ad {name = "Maison 3 chambres", location = "Rennes Cleunay", price = Just "760 €", url = "https://www.ouestfrance-immo.com//immobilier/location/maison/rennes-35-35238/11538097.htm"} - , Ad {name = "Maison 5 chambres", location = "Rennes Sud", price = Just "725 €", url = "https://www.ouestfrance-immo.com//immobilier/location/maison/rennes-35-35238/11538087.htm"} - , Ad {name = "Maison 2 pièces", location = "Rennes Sacré Coeurs", price = Just "420 €", url = "https://www.ouestfrance-immo.com//immobilier/location/maison/rennes-35-35238/12892421.htm"} - , Ad {name = "Maison 2 chambres", location = "Rennes Centre Ville", price = Just "700 €", url = "https://www.ouestfrance-immo.com//immobilier/location/maison/rennes-35-35238/11918621.htm"} - , Ad {name = "Maison 5 pièces", location = "Rennes Arsenal - Redon", price = Just "760 €", url = "https://www.ouestfrance-immo.com//immobilier/location/maison/rennes-35-35238/11139832.htm"} - , Ad {name = "Maison 2 chambres", location = "Rennes Centre Ville", price = Just "900 €", url = "https://www.ouestfrance-immo.com//immobilier/location/maison/rennes-35-35238/12247109.htm"} - , Ad {name = "Maison 4 pièces", location = "Rennes Nord Saint-Martin", price = Just "680 €", url = "https://www.ouestfrance-immo.com//immobilier/location/maison/rennes-35-35238/12973592.htm"} + [ Ad {name = "Appartement 4 pi\232ces", location = "Rennes Saint-Helier", price = Just "720\160\8364", url = "https://www.ouestfrance-immo.com//immobilier/location/appartement/rennes-35-35238/4-pieces-14207349.htm"} + , Ad {name = "Appartement 2 pi\232ces", location = "Rennes", price = Just "500\160\8364", url = "https://www.ouestfrance-immo.com//immobilier/location/appartement/rennes-35-35238/2-pieces-14207350.htm"} + , Ad {name = "Chambre", location = "Rennes Villejean", price = Just "300\160\8364", url = "https://www.ouestfrance-immo.com//immobilier/location/appartement/rennes-35-35238/chambre-14207040.htm"} + , Ad {name = "Chambre", location = "Rennes Sud", price = Just "420\160\8364", url = "https://www.ouestfrance-immo.com//immobilier/location/appartement/rennes-35-35238/chambre-14206299.htm"} + , Ad {name = "Appartement 3 pi\232ces", location = "Rennes Lorient - Saint-Brieuc", price = Just "760\160\8364", url = "https://www.ouestfrance-immo.com//immobilier/location/appartement/rennes-35-35238/3-pieces-13973525.htm"} + , Ad {name = "Appartement 4 pi\232ces", location = "Rennes Centre Ville", price = Just "1 030\160\8364", url = "https://www.ouestfrance-immo.com//immobilier/location/appartement/rennes-35-35238/4-pieces-13975591.htm"} + , Ad {name = "Appartement 2 pi\232ces", location = "Rennes Bourg L'ev\234que", price = Just "610\160\8364", url = "https://www.ouestfrance-immo.com//immobilier/location/appartement/rennes-35-35238/2-pieces-14054750.htm"} + , Ad {name = "Appartement 2 pi\232ces", location = "Rennes", price = Just "555\160\8364", url = "https://www.ouestfrance-immo.com//immobilier/location/appartement/rennes-35-35238/2-pieces-14056063.htm"} + , Ad {name = "Appartement 4 pi\232ces", location = "Rennes", price = Just "896\160\8364", url = "https://www.ouestfrance-immo.com//immobilier/location/appartement/rennes-35-35238/4-pieces-14062721.htm"} + , Ad {name = "Appartement 4 pi\232ces", location = "Rennes Villejean", price = Just "970\160\8364", url = "https://www.ouestfrance-immo.com//immobilier/location/appartement/rennes-35-35238/4-pieces-14124045.htm"} + , Ad {name = "Appartement T1", location = "Rennes", price = Just "290\160\8364", url = "https://www.ouestfrance-immo.com//immobilier/location/appartement/rennes-35-35238/t1-14142806.htm"} + , Ad {name = "Appartement 3 pi\232ces", location = "Rennes Centre Ville", price = Just "770\160\8364", url = "https://www.ouestfrance-immo.com//immobilier/location/appartement/rennes-35-35238/3-pieces-14142808.htm"} + , Ad {name = "Appartement 3 pi\232ces", location = "Rennes Centre Ville", price = Just "925\160\8364", url = "https://www.ouestfrance-immo.com//immobilier/location/appartement/rennes-35-35238/3-pieces-14168246.htm"} ] seLoger :: [Ad] seLoger = - [ Ad {name = "Appartement", location = "Paris 20ème", price = Just "1 219 €", url = "https://www.seloger.com/annonces/locations/appartement/paris-20eme-75/plaine/134448375.htm?furnished=0&places=%5b%7bcp%3a75%7d%5d&projects=1&qsversion=1.0&rooms=2&types=1&bd=ListToDetail"} - , Ad {name = "Appartement", location = "Paris 16ème", price = Just "1 500 €", url = "https://www.seloger.com/annonces/locations/appartement/paris-16eme-75/muette-sud/134049627.htm?furnished=0&places=%5b%7bcp%3a75%7d%5d&projects=1&qsversion=1.0&rooms=2&types=1&bd=ListToDetail"} - , Ad {name = "Appartement", location = "Paris 3ème", price = Just "1 595 €", url = "https://www.seloger.com/annonces/locations/appartement/paris-3eme-75/arts-et-metiers/76038037.htm?furnished=0&places=%5b%7bcp%3a75%7d%5d&projects=1&qsversion=1.0&rooms=2&types=1&bd=ListToDetail"} - , Ad {name = "Appartement", location = "Paris 15ème", price = Just "1 612 €", url = "https://www.seloger.com/annonces/locations/appartement/paris-15eme-75/citroen-boucicaut/135038561.htm?furnished=0&places=%5b%7bcp%3a75%7d%5d&projects=1&qsversion=1.0&rooms=2&types=1&bd=ListToDetail"} - , Ad {name = "Appartement", location = "Paris 16ème", price = Just "1 650 €", url = "https://www.seloger.com/annonces/locations/appartement/paris-16eme-75/auteuil-sud/133027227.htm?furnished=0&places=%5b%7bcp%3a75%7d%5d&projects=1&qsversion=1.0&rooms=2&types=1&bd=ListToDetail"} - , Ad {name = "Appartement", location = "Paris 16ème", price = Just "1 875 €", url = "https://www.seloger.com/annonces/locations/appartement/paris-16eme-75/chaillot/127190787.htm?furnished=0&places=%5b%7bcp%3a75%7d%5d&projects=1&qsversion=1.0&rooms=2&types=1&bd=ListToDetail"} - , Ad {name = "Appartement", location = "Paris 8ème", price = Just "1 985 €", url = "https://www.seloger.com/annonces/locations/appartement/paris-8eme-75/saint-philippe-du-roule/127109353.htm?furnished=0&places=%5b%7bcp%3a75%7d%5d&projects=1&qsversion=1.0&rooms=2&types=1&bd=ListToDetail"} - , Ad {name = "Appartement", location = "Paris 1er", price = Just "2 090 €", url = "https://www.seloger.com/annonces/locations/appartement/paris-1er-75/ile-de-la-cite/133982099.htm?furnished=0&places=%5b%7bcp%3a75%7d%5d&projects=1&qsversion=1.0&rooms=2&types=1&bd=ListToDetail"} - , Ad {name = "Appartement", location = "Paris 16ème", price = Just "2 240 €", url = "https://www.seloger.com/annonces/locations/appartement/paris-16eme-75/porte-dauphine/118523093.htm?furnished=0&places=%5b%7bcp%3a75%7d%5d&projects=1&qsversion=1.0&rooms=2&types=1&bd=ListToDetail"} - , Ad {name = "Appartement", location = "Paris 17ème", price = Just "2 400 €", url = "https://www.seloger.com/annonces/locations/appartement/paris-17eme-75/champerret-berthier/134621503.htm?furnished=0&places=%5b%7bcp%3a75%7d%5d&projects=1&qsversion=1.0&rooms=2&types=1&bd=ListToDetail"} - , Ad {name = "Appartement", location = "Paris 6ème", price = Just "2 055 €", url = "https://www.seloger.com/annonces/locations/appartement/paris-6eme-75/saint-germain-des-pres/130192167.htm?furnished=0&places=%5b%7bcp%3a75%7d%5d&projects=1&qsversion=1.0&rooms=2&types=1&bd=ListToDetail"} - , Ad {name = "Appartement", location = "Paris 14ème", price = Just "1 300 €", url = "https://www.seloger.com/annonces/locations/appartement/paris-14eme-75/jean-moulin-porte-d-orleans/133269543.htm?furnished=0&places=%5b%7bcp%3a75%7d%5d&projects=1&qsversion=1.0&rooms=2&types=1&bd=ListToDetail"} - , Ad {name = "Appartement", location = "Paris 16ème", price = Just "3 500 €", url = "https://www.bellesdemeures.com/annonces/locations/appartement/paris-16eme-75/133260359.htm?bd=CartoToList_SL&furnished=0&places=%5b%7bcp%3a75%7d%5d&projects=1&qsversion=1.0&rooms=2&types=1&cmp=INTSL_ListToDetail"} - , Ad {name = "Appartement", location = "Paris 17ème", price = Just "1 890 €", url = "https://www.seloger.com/annonces/locations/appartement/paris-17eme-75/134972009.htm?furnished=0&places=%5b%7bcp%3a75%7d%5d&projects=1&qsversion=1.0&rooms=2&types=1&bd=ListToDetail"} - , Ad {name = "Appartement", location = "Paris 18ème", price = Just "1 390 €", url = "https://www.seloger.com/annonces/locations/appartement/paris-18eme-75/clignancourt-jules-joffrin/134735501.htm?furnished=0&places=%5b%7bcp%3a75%7d%5d&projects=1&qsversion=1.0&rooms=2&types=1&bd=ListToDetail"} - , Ad {name = "Appartement", location = "Paris 6ème", price = Just "1 600 €", url = "https://www.seloger.com/annonces/locations/appartement/paris-6eme-75/saint-germain-des-pres/134437989.htm?furnished=0&places=%5b%7bcp%3a75%7d%5d&projects=1&qsversion=1.0&rooms=2&types=1&bd=ListToDetail"} - , Ad {name = "Appartement", location = "Paris 11ème", price = Just "1 980 €", url = "https://www.seloger.com/annonces/locations/appartement/paris-11eme-75/bastille-popincourt/134314607.htm?furnished=0&places=%5b%7bcp%3a75%7d%5d&projects=1&qsversion=1.0&rooms=2&types=1&bd=ListToDetail"} - , Ad {name = "Appartement", location = "Paris 13ème", price = Just "901 €", url = "https://www.seloger.com/annonces/locations/appartement/paris-13eme-75/olympiades-choisy/134428153.htm?furnished=0&places=%5b%7bcp%3a75%7d%5d&projects=1&qsversion=1.0&rooms=2&types=1&bd=ListToDetail"} - , Ad {name = "Appartement", location = "Paris 12ème", price = Just "1 250 €", url = "https://www.seloger.com/annonces/locations/appartement/paris-12eme-75/aligre-gare-de-lyon/133908165.htm?furnished=0&places=%5b%7bcp%3a75%7d%5d&projects=1&qsversion=1.0&rooms=2&types=1&bd=ListToDetail"} - , Ad {name = "Appartement", location = "Paris 17ème", price = Just "1 100 €", url = "https://www.seloger.com/annonces/locations/appartement/paris-17eme-75/legendre-levis/134131479.htm?furnished=0&places=%5b%7bcp%3a75%7d%5d&projects=1&qsversion=1.0&rooms=2&types=1&bd=ListToDetail"} + [ Ad {name = "Appartement", location = "Paris 16\232me", price = Just "3 650 \8364", url = "https://www.seloger.com/annonces/locations/appartement/paris-16eme-75/chaillot/148235057.htm?cp=75&enterprise=0&idtt=1&idtypebien=1&naturebien=1&tri=initial&bd=ListToDetail"} + , Ad {name = "Appartement", location = "Paris 16\232me", price = Just "4 015 \8364", url = "https://www.bellesdemeures.com/annonces/locations/appartement-luxe/paris-16eme-75/porte-dauphine/149009059.htm?cp=75&enterprise=0&idtt=1&idtypebien=1&naturebien=1&tri=initial&cmp=INTSL_ListToDetail"} + , Ad {name = "Appartement", location = "Paris 5\232me", price = Just "1 450 \8364", url = "https://www.seloger.com/annonces/locations/appartement/paris-5eme-75/sorbonne/149225373.htm?cp=75&enterprise=0&idtt=1&idtypebien=1&naturebien=1&tri=initial&bd=ListToDetail"} + , Ad {name = "Appartement", location = "Paris 7\232me", price = Just "5 000 \8364", url = "https://www.seloger.com/annonces/locations/appartement/paris-7eme-75/ecole-militaire/147818465.htm?cp=75&enterprise=0&idtt=1&idtypebien=1&naturebien=1&tri=initial&bd=ListToDetail"} + , Ad {name = "Appartement", location = "Paris 10\232me", price = Just "1 600 \8364", url = "https://www.seloger.com/annonces/locations/appartement/paris-10eme-75/saint-vincent-de-paul-lariboisiere/147922011.htm?cp=75&enterprise=0&idtt=1&idtypebien=1&naturebien=1&tri=initial&bd=ListToDetail"} + , Ad {name = "Appartement", location = "Paris 10\232me", price = Just "1 595 \8364", url = "https://www.seloger.com/annonces/locations/appartement/paris-10eme-75/faubourg-du-temple-hopital-saint-louis/71190089.htm?cp=75&enterprise=0&idtt=1&idtypebien=1&naturebien=1&tri=initial&bd=ListToDetail"} + , Ad {name = "Appartement", location = "Paris 1er", price = Just "3 600 \8364", url = "https://www.bellesdemeures.com/annonces/locations/appartement-luxe/paris-1er-75/vendome/105348057.htm?cp=75&enterprise=0&idtt=1&idtypebien=1&naturebien=1&tri=initial&cmp=INTSL_ListToDetail"} + , Ad {name = "Appartement neuf", location = "Paris 8\232me", price = Just "4 700 \8364", url = "https://www.bellesdemeures.com/annonces/locations/appartement-luxe/paris-8eme-75/triangle-d-or/128620797.htm?cp=75&enterprise=0&idtt=1&idtypebien=1&naturebien=1&tri=initial&cmp=INTSL_ListToDetail"} + , Ad {name = "Appartement", location = "Paris 5\232me", price = Just "1 700 \8364", url = "https://www.seloger.com/annonces/locations/appartement/paris-5eme-75/sorbonne/131897651.htm?cp=75&enterprise=0&idtt=1&idtypebien=1&naturebien=1&tri=initial&bd=ListToDetail"} + , Ad {name = "Appartement", location = "Paris 8\232me", price = Just "1 700 \8364", url = "https://www.seloger.com/annonces/locations/appartement/paris-8eme-75/parc-monceau/132264705.htm?cp=75&enterprise=0&idtt=1&idtypebien=1&naturebien=1&tri=initial&bd=ListToDetail"} + , Ad {name = "Appartement", location = "Paris 8\232me", price = Just "15 000 \8364", url = "https://www.bellesdemeures.com/annonces/locations/appartement-luxe/paris-8eme-75/triangle-d-or/140307389.htm?cp=75&enterprise=0&idtt=1&idtypebien=1&naturebien=1&tri=initial&cmp=INTSL_ListToDetail"} + , Ad {name = "Appartement", location = "Paris 16\232me", price = Just "3 620 \8364", url = "https://www.seloger.com/annonces/locations/appartement/paris-16eme-75/chaillot/140510373.htm?cp=75&enterprise=0&idtt=1&idtypebien=1&naturebien=1&tri=initial&bd=ListToDetail"} + , Ad {name = "Appartement", location = "Paris 8\232me", price = Just "7 540 \8364", url = "https://www.seloger.com/annonces/locations/appartement/paris-8eme-75/saint-philippe-du-roule/140646657.htm?cp=75&enterprise=0&idtt=1&idtypebien=1&naturebien=1&tri=initial&bd=ListToDetail"} + , Ad {name = "Appartement", location = "Paris 8\232me", price = Just "4 390 \8364", url = "https://www.seloger.com/annonces/locations/appartement/paris-8eme-75/saint-philippe-du-roule/140648971.htm?cp=75&enterprise=0&idtt=1&idtypebien=1&naturebien=1&tri=initial&bd=ListToDetail"} + , Ad {name = "Appartement", location = "Paris 8\232me", price = Just "3 500 \8364", url = "https://www.bellesdemeures.com/annonces/locations/appartement-luxe/paris-8eme-75/triangle-d-or/141066621.htm?cp=75&enterprise=0&idtt=1&idtypebien=1&naturebien=1&tri=initial&cmp=INTSL_ListToDetail"} + , Ad {name = "Appartement", location = "Paris 16\232me", price = Just "5 000 \8364", url = "https://www.seloger.com/annonces/locations/appartement/paris-16eme-75/porte-dauphine/143270633.htm?cp=75&enterprise=0&idtt=1&idtypebien=1&naturebien=1&tri=initial&bd=ListToDetail"} + , Ad {name = "Appartement", location = "Paris 14\232me", price = Just "1 670 \8364", url = "https://www.seloger.com/annonces/locations/appartement/paris-14eme-75/mouton-duvernet/143388609.htm?cp=75&enterprise=0&idtt=1&idtypebien=1&naturebien=1&tri=initial&bd=ListToDetail"} + , Ad {name = "Appartement", location = "Paris 7\232me", price = Just "3 200 \8364", url = "https://www.bellesdemeures.com/annonces/locations/appartement-luxe/paris-7eme-75/ecole-militaire/144228595.htm?cp=75&enterprise=0&idtt=1&idtypebien=1&naturebien=1&tri=initial&cmp=INTSL_ListToDetail"} + , Ad {name = "Appartement", location = "Paris 19\232me", price = Just "1 552 \8364", url = "https://www.seloger.com/annonces/locations/appartement/paris-19eme-75/flandre-aubervilliers/144764173.htm?cp=75&enterprise=0&idtt=1&idtypebien=1&naturebien=1&tri=initial&bd=ListToDetail"} + , Ad {name = "Appartement", location = "Paris 15\232me", price = Just "2 871 \8364", url = "https://www.seloger.com/annonces/locations/appartement/paris-15eme-75/pasteur-montparnasse/145485275.htm?cp=75&enterprise=0&idtt=1&idtypebien=1&naturebien=1&tri=initial&bd=ListToDetail"} ] diff --git a/src/test/haskell/ParserSpec.hs b/src/test/haskell/ParserSpec.hs index 64b2b33..00840c7 100644 --- a/src/test/haskell/ParserSpec.hs +++ b/src/test/haskell/ParserSpec.hs @@ -1,21 +1,22 @@ module ParserSpec (spec) where -import Data.Maybe (catMaybes) -import qualified Data.Text.IO as T -import qualified Network.Wreq.Session as Session +import Data.Maybe (catMaybes) +import qualified Data.Text.IO as T +import qualified Network.Wreq.Session as Session import Test.Hspec import qualified Ads import qualified FetchAd -import Model.Ad (Ad (..)) -import qualified Parser.LeboncoinParser as LeboncoinParser --- import qualified Parser.OuestFranceParser as OuestFranceParser --- import qualified Parser.SeLogerParser as SeLogerParser +import Model.Ad (Ad (..)) +import qualified Parser.LeboncoinParser as LeboncoinParser +import qualified Parser.OuestFranceParser as OuestFranceParser +import qualified Parser.SeLogerParser as SeLogerParser spec :: Spec spec = do describe "Parser" $ do session <- runIO Session.newSession + describe "LeBonCoin" $ do it "should parse no results from empty string" $ do @@ -31,31 +32,35 @@ spec = do ["https://www.leboncoin.fr/annonces/offres/ile_de_france/"] checkAds ads - -- describe "OuestFrance" $ do - -- - -- it "should parse no results from empty string" $ do - -- OuestFranceParser.parse "" `shouldBe` [] - -- - -- it "should parse ads from page" $ do - -- rawOuestFranceAds <- T.readFile "src/test/resources/ouestFrance.html" - -- OuestFranceParser.parse rawOuestFranceAds `shouldBe` Ads.ouestFrance - -- - -- it "should parse ads from remote page" $ do - -- ads <- FetchAd.ouestFrance ["https://www.ouestfrance-immo.com/louer/appartement/rennes-35-35000/"] - -- checkAds ads - -- - -- describe "SeLoger" $ do - -- - -- it "should parse no results from empty string" $ do - -- SeLogerParser.parse "" `shouldBe` [] - -- - -- it "should parse ads from page" $ do - -- ads <- T.readFile "src/test/resources/seLoger.html" - -- SeLogerParser.parse ads `shouldBe` Ads.seLoger - -- - -- it "should parse ads from remote page" $ do - -- ads <- FetchAd.seLoger ["https://www.seloger.com/list.htm?tri=initial&idtypebien=2,1&idtt=2,5&naturebien=1,2,4&ci=690123"] - -- checkAds ads + describe "OuestFrance" $ do + + it "should parse no results from empty string" $ do + OuestFranceParser.parse "" `shouldBe` [] + + it "should parse ads from page" $ do + rawOuestFranceAds <- T.readFile "src/test/resources/ouestFrance.html" + OuestFranceParser.parse rawOuestFranceAds `shouldBe` Ads.ouestFrance + + it "should parse ads from remote page" $ do + ads <- FetchAd.ouestFrance + session + ["https://www.ouestfrance-immo.com/louer/appartement/rennes-35-35000/"] + checkAds ads + + describe "SeLoger" $ do + + it "should parse no results from empty string" $ do + SeLogerParser.parse "" `shouldBe` [] + + it "should parse ads from page" $ do + ads <- T.readFile "src/test/resources/seLoger.html" + SeLogerParser.parse ads `shouldBe` Ads.seLoger + + it "should parse ads from remote page" $ do + ads <- FetchAd.seLoger + session + ["https://www.seloger.com/list.htm?tri=initial&idtypebien=2,1&idtt=2,5&naturebien=1,2,4&ci=690123"] + checkAds ads checkAds :: [Ad] -> IO () checkAds ads = do diff --git a/src/test/resources/ouestFrance.html b/src/test/resources/ouestFrance.html index 5616252..ab7bdf0 100644 --- a/src/test/resources/ouestFrance.html +++ b/src/test/resources/ouestFrance.html @@ -5,16 +5,16 @@ -Ouestfrance-immo: Annonces immobilières | Location, vente, achat immobilierLocation maison Rennes (35) - à louer Rennes (35) - Annonces Immobilieres Location maison Rennes (35) +Ouestfrance-immo: Annonces immobilières | Location, vente, achat immobilierLocation appartement Rennes (35) - à louer Rennes (35) - Annonces Immobilieres Location appartement Rennes (35) - + - + @@ -24,40 +24,91 @@ - - - - + + + + - + - + + + - - + + - +
@@ -398,11 +464,13 @@ document.cookie="contextRechercheJs=transaction=L#type=maison#typeId=216#classif ›  Rennes ›  - Location + Location + ›  +

- 34 + 171 LOCATIONS à Rennes
dont sur la carte
@@ -489,7 +557,7 @@ document.cookie="contextRechercheJs=transaction=L#type=maison#typeId=216#classif style="display:none;" > - Maison + Appartement - - - - - - - - -
-
- -
-
- - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - -
-
+ -
+
+
+
-
+
+ @@ -18950,16 +19972,14 @@ var bm = "" || (!!document.querySelector("meta[name='cleanMods']") + -
  • - - Location appartement 4 pièces - 600 annonces - - + -
  • + +
    +