diff options
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/haskell/Ads.hs | 97 | ||||
-rw-r--r-- | src/test/haskell/Main.hs | 116 |
2 files changed, 121 insertions, 92 deletions
diff --git a/src/test/haskell/Ads.hs b/src/test/haskell/Ads.hs new file mode 100644 index 0000000..85a5471 --- /dev/null +++ b/src/test/haskell/Ads.hs @@ -0,0 +1,97 @@ +module Ads + ( leboncoin + , ouestFrance + , seLoger + ) where + +import Model.Ad (Ad (..)) + +leboncoin :: [Ad] +leboncoin = + [ Ad {name = "Chambre style hotel", location = "Dinan", price = Just "265 €", url = "https://www.leboncoin.fr/locations/1450271298.htm?ca=6_s"} + , Ad {name = "Centre ville", location = "Brest", price = Just "420 €", url = "https://www.leboncoin.fr/locations/1450271056.htm?ca=6_s"} + , Ad {name = "T3, Morlaix proche centre ville et port plaisance", location = "Morlaix", price = Just "395 €", url = "https://www.leboncoin.fr/locations/1407544500.htm?ca=6_s"} + , Ad {name = "Appartement meuble", location = "Rennes", price = Just "565 €", url = "https://www.leboncoin.fr/locations/1377975959.htm?ca=6_s"} + , Ad {name = "A louer T3", location = "La Chapelle-Janson", price = Just "420 €", url = "https://www.leboncoin.fr/locations/1450270098.htm?ca=6_s"} + , Ad {name = "locations garage / garde meuble", location = "Landerneau", price = Just "50 €", url = "https://www.leboncoin.fr/locations/1450174538.htm?ca=6_s"} + , Ad {name = "Studio meublé", location = "Lanester", price = Just "290 €", url = "https://www.leboncoin.fr/locations/1450268170.htm?ca=6_s"} + , Ad {name = "Ergué-Gabéric - Maison - 3 chambres -", location = "Ergué-Gabéric", price = Just "655 €", url = "https://www.leboncoin.fr/locations/1450267530.htm?ca=6_s"} + , Ad {name = "Studio meublé à 2 mn de la gare", location = "Rennes", price = Just "475 €", url = "https://www.leboncoin.fr/locations/1450267333.htm?ca=6_s"} + , Ad {name = "Chambre à louer chez l,habitant", location = "Rennes", price = Just "450 €", url = "https://www.leboncoin.fr/locations/1450266273.htm?ca=6_s"} + , Ad {name = "Appartement 3 pièces 63 m\178", location = "Brest", price = Just "600 €", url = "https://www.leboncoin.fr/locations/1426927284.htm?ca=6_s"} + , Ad {name = "recherche location", location = "Plaintel", price = Just "550 €", url = "https://www.leboncoin.fr/locations/1450265866.htm?ca=6_s"} + , Ad {name = "Studio rénové - Centre Ville Lorient", location = "Lorient", price = Just "360 €", url = "https://www.leboncoin.fr/locations/1450265154.htm?ca=6_s"} + , Ad {name = "Centre historique, t2 meuble", location = "Vannes", price = Just "440 €", url = "https://www.leboncoin.fr/locations/1450263864.htm?ca=6_s"} + , Ad {name = "appartement t3 parking privé", location = "Pontrieux", price = Just "390 €", url = "https://www.leboncoin.fr/locations/1450251207.htm?ca=6_s"} + , Ad {name = "T1 Bis espace couchage indépendant", location = "Brest", price = Just "360 €", url = "https://www.leboncoin.fr/locations/1450263863.htm?ca=6_s"} + , Ad {name = "Grand T2 boulevard Gambetta", location = "Brest", price = Just "400 €", url = "https://www.leboncoin.fr/locations/1450263306.htm?ca=6_s"} + , Ad {name = "chambre meublée", location = "Bourg-des-Comptes", price = Just "300 €", url = "https://www.leboncoin.fr/locations/1450246530.htm?ca=6_s"} + , Ad {name = "Un studio de charme au centre de Landerneau", location = "Landerneau", price = Just "310 €", url = "https://www.leboncoin.fr/locations/1433376198.htm?ca=6_s"} + , Ad {name = "Appartement T2 plein centre.", location = "Pluméliau", price = Just "385 €", url = "https://www.leboncoin.fr/locations/1450262744.htm?ca=6_s"} + , Ad {name = "Recherche l'appartement parfait", location = "Rennes", price = Just "360 €", url = "https://www.leboncoin.fr/locations/1450260894.htm?ca=6_s"} + , Ad {name = "Location appartement meuble", location = "Saint-Malo", price = Just "510 €", url = "https://www.leboncoin.fr/locations/1421964890.htm?ca=6_s"} + , Ad {name = "Maison neuve Lambezelec", location = "Plabennec", price = Just "900 €", url = "https://www.leboncoin.fr/locations/1450259912.htm?ca=6_s"} + , Ad {name = "Chambre kitchenette chez l'habitant", location = "Brest", price = Just "320 €", url = "https://www.leboncoin.fr/locations/1450258838.htm?ca=6_s"} + , Ad {name = "Studio 20m2 Rennes Ouest", location = "Rennes", price = Just "395 €", url = "https://www.leboncoin.fr/locations/1450258223.htm?ca=6_s"} + , Ad {name = "Maison Ploufragan", location = "Ploufragan", price = Just "680 €", url = "https://www.leboncoin.fr/locations/1450257866.htm?ca=6_s"} + , Ad {name = "Studio centre villes Rennes", location = "Rennes", price = Just "425 €", url = "https://www.leboncoin.fr/locations/1450257277.htm?ca=6_s"} + , Ad {name = "Grand T2 Saint-Brieuc proche Renan", location = "Saint-Brieuc", price = Just "375 €", url = "https://www.leboncoin.fr/locations/1450257042.htm?ca=6_s"} + , Ad {name = "Location maison T3", location = "Langueux", price = Just "569 €", url = "https://www.leboncoin.fr/locations/1439054110.htm?ca=6_s"} + , Ad {name = "Chambre", location = "Vannes", price = Just "150 €", url = "https://www.leboncoin.fr/locations/1450255229.htm?ca=6_s"} + , Ad {name = "Appartement meublé 2 ch centre Brest", location = "Brest", price = Just "750 €", url = "https://www.leboncoin.fr/locations/1450255216.htm?ca=6_s"} + , Ad {name = "Brest Base Navale/porte Caffa - possible meublé", location = "Brest", price = Just "390 €", url = "https://www.leboncoin.fr/locations/1433862279.htm?ca=6_s"} + , Ad {name = "Appartement Rennes", location = "Rennes", price = Just "390 €", url = "https://www.leboncoin.fr/locations/1450254830.htm?ca=6_s"} + , Ad {name = "Location Appartement Villejean", location = "Rennes", price = Just "400 €", url = "https://www.leboncoin.fr/locations/1450253542.htm?ca=6_s"} + , Ad {name = "Maison de bourg 3 chambres Bédée", location = "Bédée", price = Just "570 €", url = "https://www.leboncoin.fr/locations/1450252631.htm?ca=6_s"} + ] + +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"} + ] + +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"} + ] diff --git a/src/test/haskell/Main.hs b/src/test/haskell/Main.hs index fa86d27..a8cfae9 100644 --- a/src/test/haskell/Main.hs +++ b/src/test/haskell/Main.hs @@ -1,6 +1,9 @@ +import Data.Maybe (catMaybes) import qualified Data.Text.IO as T 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 @@ -8,56 +11,19 @@ import qualified Parser.SeLogerParser as SeLogerParser main :: IO () main = do - rawLeboncoinAds <- T.readFile "src/test/resources/leboncoin.html" - rawOuestFranceAds <- T.readFile "src/test/resources/ouestFrance.html" - rawSeLogerParser <- T.readFile "src/test/resources/seLoger.html" - hspec $ do describe "LeboncoinParser" $ do it "should parse no results from empty string" $ do LeboncoinParser.parse "" `shouldBe` [] - it "should parse ads from page" $ do - let ads = - [ Ad {name = "Chambre style hotel", location = "Dinan", price = Just "265 €", url = "https://www.leboncoin.fr/locations/1450271298.htm?ca=6_s"} - , Ad {name = "Centre ville", location = "Brest", price = Just "420 €", url = "https://www.leboncoin.fr/locations/1450271056.htm?ca=6_s"} - , Ad {name = "T3, Morlaix proche centre ville et port plaisance", location = "Morlaix", price = Just "395 €", url = "https://www.leboncoin.fr/locations/1407544500.htm?ca=6_s"} - , Ad {name = "Appartement meuble", location = "Rennes", price = Just "565 €", url = "https://www.leboncoin.fr/locations/1377975959.htm?ca=6_s"} - , Ad {name = "A louer T3", location = "La Chapelle-Janson", price = Just "420 €", url = "https://www.leboncoin.fr/locations/1450270098.htm?ca=6_s"} - , Ad {name = "locations garage / garde meuble", location = "Landerneau", price = Just "50 €", url = "https://www.leboncoin.fr/locations/1450174538.htm?ca=6_s"} - , Ad {name = "Studio meublé", location = "Lanester", price = Just "290 €", url = "https://www.leboncoin.fr/locations/1450268170.htm?ca=6_s"} - , Ad {name = "Ergué-Gabéric - Maison - 3 chambres -", location = "Ergué-Gabéric", price = Just "655 €", url = "https://www.leboncoin.fr/locations/1450267530.htm?ca=6_s"} - , Ad {name = "Studio meublé à 2 mn de la gare", location = "Rennes", price = Just "475 €", url = "https://www.leboncoin.fr/locations/1450267333.htm?ca=6_s"} - , Ad {name = "Chambre à louer chez l,habitant", location = "Rennes", price = Just "450 €", url = "https://www.leboncoin.fr/locations/1450266273.htm?ca=6_s"} - , Ad {name = "Appartement 3 pièces 63 m\178", location = "Brest", price = Just "600 €", url = "https://www.leboncoin.fr/locations/1426927284.htm?ca=6_s"} - , Ad {name = "recherche location", location = "Plaintel", price = Just "550 €", url = "https://www.leboncoin.fr/locations/1450265866.htm?ca=6_s"} - , Ad {name = "Studio rénové - Centre Ville Lorient", location = "Lorient", price = Just "360 €", url = "https://www.leboncoin.fr/locations/1450265154.htm?ca=6_s"} - , Ad {name = "Centre historique, t2 meuble", location = "Vannes", price = Just "440 €", url = "https://www.leboncoin.fr/locations/1450263864.htm?ca=6_s"} - , Ad {name = "appartement t3 parking privé", location = "Pontrieux", price = Just "390 €", url = "https://www.leboncoin.fr/locations/1450251207.htm?ca=6_s"} - , Ad {name = "T1 Bis espace couchage indépendant", location = "Brest", price = Just "360 €", url = "https://www.leboncoin.fr/locations/1450263863.htm?ca=6_s"} - , Ad {name = "Grand T2 boulevard Gambetta", location = "Brest", price = Just "400 €", url = "https://www.leboncoin.fr/locations/1450263306.htm?ca=6_s"} - , Ad {name = "chambre meublée", location = "Bourg-des-Comptes", price = Just "300 €", url = "https://www.leboncoin.fr/locations/1450246530.htm?ca=6_s"} - , Ad {name = "Un studio de charme au centre de Landerneau", location = "Landerneau", price = Just "310 €", url = "https://www.leboncoin.fr/locations/1433376198.htm?ca=6_s"} - , Ad {name = "Appartement T2 plein centre.", location = "Pluméliau", price = Just "385 €", url = "https://www.leboncoin.fr/locations/1450262744.htm?ca=6_s"} - , Ad {name = "Recherche l'appartement parfait", location = "Rennes", price = Just "360 €", url = "https://www.leboncoin.fr/locations/1450260894.htm?ca=6_s"} - , Ad {name = "Location appartement meuble", location = "Saint-Malo", price = Just "510 €", url = "https://www.leboncoin.fr/locations/1421964890.htm?ca=6_s"} - , Ad {name = "Maison neuve Lambezelec", location = "Plabennec", price = Just "900 €", url = "https://www.leboncoin.fr/locations/1450259912.htm?ca=6_s"} - , Ad {name = "Chambre kitchenette chez l'habitant", location = "Brest", price = Just "320 €", url = "https://www.leboncoin.fr/locations/1450258838.htm?ca=6_s"} - , Ad {name = "Studio 20m2 Rennes Ouest", location = "Rennes", price = Just "395 €", url = "https://www.leboncoin.fr/locations/1450258223.htm?ca=6_s"} - , Ad {name = "Maison Ploufragan", location = "Ploufragan", price = Just "680 €", url = "https://www.leboncoin.fr/locations/1450257866.htm?ca=6_s"} - , Ad {name = "Studio centre villes Rennes", location = "Rennes", price = Just "425 €", url = "https://www.leboncoin.fr/locations/1450257277.htm?ca=6_s"} - , Ad {name = "Grand T2 Saint-Brieuc proche Renan", location = "Saint-Brieuc", price = Just "375 €", url = "https://www.leboncoin.fr/locations/1450257042.htm?ca=6_s"} - , Ad {name = "Location maison T3", location = "Langueux", price = Just "569 €", url = "https://www.leboncoin.fr/locations/1439054110.htm?ca=6_s"} - , Ad {name = "Chambre", location = "Vannes", price = Just "150 €", url = "https://www.leboncoin.fr/locations/1450255229.htm?ca=6_s"} - , Ad {name = "Appartement meublé 2 ch centre Brest", location = "Brest", price = Just "750 €", url = "https://www.leboncoin.fr/locations/1450255216.htm?ca=6_s"} - , Ad {name = "Brest Base Navale/porte Caffa - possible meublé", location = "Brest", price = Just "390 €", url = "https://www.leboncoin.fr/locations/1433862279.htm?ca=6_s"} - , Ad {name = "Appartement Rennes", location = "Rennes", price = Just "390 €", url = "https://www.leboncoin.fr/locations/1450254830.htm?ca=6_s"} - , Ad {name = "Location Appartement Villejean", location = "Rennes", price = Just "400 €", url = "https://www.leboncoin.fr/locations/1450253542.htm?ca=6_s"} - , Ad {name = "Maison de bourg 3 chambres Bédée", location = "Bédée", price = Just "570 €", url = "https://www.leboncoin.fr/locations/1450252631.htm?ca=6_s"} - ] + it "should parse ads from local page" $ do + ads <- T.readFile "src/test/resources/leboncoin.html" + LeboncoinParser.parse ads `shouldBe` Ads.leboncoin - LeboncoinParser.parse rawLeboncoinAds `shouldBe` ads + it "should parse ads from remote page" $ do + ads <- FetchAd.leboncoin ["https://www.leboncoin.fr/locations/offres/ile_de_france/?th=1"] + checkAds ads describe "OuestFranceParser" $ do @@ -65,33 +31,12 @@ main = do OuestFranceParser.parse "" `shouldBe` [] it "should parse ads from page" $ do - let ads = - [ 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"} - ] + rawOuestFranceAds <- T.readFile "src/test/resources/ouestFrance.html" + OuestFranceParser.parse rawOuestFranceAds `shouldBe` Ads.ouestFrance - OuestFranceParser.parse rawOuestFranceAds `shouldBe` ads + it "should parse ads from remote page" $ do + ads <- FetchAd.ouestFrance ["https://www.ouestfrance-immo.com/louer/appartement/rennes-35-35000/"] + checkAds ads describe "SeLogerParser" $ do @@ -99,27 +44,14 @@ main = do SeLogerParser.parse "" `shouldBe` [] it "should parse ads from page" $ do - let ads = - [ 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"} - ] + 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 - SeLogerParser.parse rawSeLogerParser `shouldBe` ads +checkAds :: [Ad] -> IO () +checkAds ads = do + length ads `shouldSatisfy` (\n -> n > 10) + (length . catMaybes . map price $ ads) `shouldSatisfy` (\n -> n > 10) |