Giter Site home page Giter Site logo

leboncoin-api's Introduction

leboncoin-api Build Status Coverage Status

NPM

/!\ leboncoin.fr is using DataDome to protect his API from library likes this one, currently all the requests are blocked /!\

Documentation

The documentation of the library is available here: https://durieux.me/projects/leboncoin.html.

Install

npm install leboncoin-api

Features

  • Search on leboncoin.fr with all functionality available leboncoin.fr
  • Get the detailed page of an item
  • Get the phone number of the seller (convert the image to string) /!\ This API have an unknown usage limit

Usage

const leboncoin = require('leboncoin-api');
var search = new leboncoin.Search()
    .setPage(1)
    .setQuery("renove")
    .setFilter(leboncoin.FILTERS.PARTICULIER)
    .setCategory("locations")
    .setRegion("ile_de_france")
    .setDepartment("yvelines")
    .setLocation([
                 {"zipcode": "78100"},
                 {"zipcode": "78000"},
                 ])
//Search around you with latitude and longitude of your position and a radius in meters. Doing so you don't need to set Region, Department and Location
//Exemple for 30km around Lyon
//.setArea({"lat": 45.7679705, "lng": 4.8637901999999995, "radius": 30000})

    //Add sort, two kind date or price and two ways asc or desc
    //Exemple for a sort by date asc (older the first)
    //.setSort({sort_by:"date",sort_order:"asc"})

    .addSearchExtra("price", {min: 1500, max: 2000}) // will add a range of price
    .addSearchExtra('furnished', ["1", "Non meublé"]); // will add enums for Meublé and Non meublé

// Please check into categories & sub categories constants to know which are the sub categories to add into "addSearchExtra"

search.run().then(function (data) {
    console.log(data.page); // the current page
    console.log(data.pages); // the number of pages
    console.log(data.nbResult); // the number of results for this search
    console.log(data.results); // the array of results
    data.results[0].getDetails().then(function (details) {
        console.log(details); // the item 0 with more data such as description, all images, author, ...
    }, function (err) {
        console.error(err);
    });
    data.results[0].getPhoneNumber().then(function (phoneNumer) {
        console.log(phoneNumer); // the phone number of the author if available
    }, function (err) {
        console.error(err); // if the phone number is not available or not parsable (image -> string) 
    });
}, function (err) {
    console.error(err);
});

License MIT

leboncoin-api's People

Contributors

deepsilence avatar dependabot[bot] avatar dragma avatar gnn06 avatar julienmalige avatar myrevers avatar nicolsc avatar othke avatar rodolphegohard avatar sylvain-d avatar tchoisy avatar tdurieux avatar tucsky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

leboncoin-api's Issues

Filter issue

In search.js line 121 suggesting to write
"f": this.filter.value,

limitation information

This is not really an issue but it's the only place I found to post my question.

While trying your library, I get Cannot retrieve the phone number URI. You may exceed your API quota.
Do you know what can I do to be back under the quota ?
Is it during a time window ?

Thank you

Evolution of location format

Hello,

Thank you for the library. I noticed that the location filter from the latest API version does not match the generated filter from the library.

{
    "filters": {
        "location": {
            "locations": [{
                "city": "Nantes",
                "zipcode": "44000",
                "label": "Nantes (44000)",
                "region_id": "18",
                "department_id": "44",
                "locationType": "city"
            }, {
                "city": "Nantes",
                "zipcode": "44200",
                "label": "Nantes (44200)",
                "region_id": "18",
                "department_id": "44",
                "locationType": "city"
            }]
        }
    }
}

But with the library I can only generate:

{
    "filters": {
        "location": {
            "city_zipcodes": [{
                    "zipcode": "44000"
                },
                {
                    "zipcode": "44200"
                },
            ],
            "region": "18",
            "department": "44"
        }
    }
}

Should I create a pull request to generate a location filter according to the latest version ?

Error item.js (line 59 cleanString(seller.html().trim()))

With [email protected] , since few days, I got this error

execution --> 2018-2-22 22:00:10 GMT+1
/volume1/dev/projets/node_modules/leboncoin-api/lib/item.js:59
return cleanString(seller.html().trim());
^
TypeError: Cannot read property 'trim' of null
at parseSeller (/volume1/dev/projets/node_modules/leboncoin-api/lib/item.js:59:37)
at Request._callback (/volume1/dev/projets/node_modules/leboncoin-api/lib/item.js:159:27)
at Request.self.callback (/volume1/dev/projets/node_modules/request/request.js:186:22)
...

API not returning results

Hi,

Since yesterday the API does not return any results on previously working queries. When debugging from lib/search.js I see the content returned by the search API only contains content like:

{"url":"https://c.datado.me/captcha/?initialCid=AHrlqAAAAAMAfhnhHfj6eVIAMw89Zw==&hash=05B30BD9055986BD2EE8F5A199D973&t=fe"}

so it looks like some captcha validation is expected ...from an API call, weird.

Simplify by using phone number json api

Just a suggestion as there is a json api

curl 'https://api.leboncoin.fr/api/utils/phonenumber.json' -H 'Origin: https://www.leboncoin.fr' -H 'Accept-Encoding: gzip, deflate, br' -H 'Accept-Language: en-US,en;q=0.8,fr;q=0.6' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: _/_' -H 'Referer: https://www.leboncoin.fr/ventes_immobilieres/986418621.htm?ca=12_s' -H 'Connection: keep-alive' --data 'list_id=986418621&app_id=leboncoin_web_utils&key=54bb0281238b45a03f0ee695f73e704f&text=1' --compressed

returns:

{"utils":{"status":"OK","phonenumber":"0664104902"}}

search.js Promise undefined

Nice work ! Congratulations and thanks for sharing.
Just trying to use it this morning.
So far only used Search. Seems to me that
const Promise = require('pinkie-promise');
is necessary in search.js.
Also npm install pinkie-promise at the leboncoin-api directory level

getDetails fails

I took the README example and get an error with getDetails function:

undefined:1
<!--
^

SyntaxError: Unexpected token < in JSON at position 0
    at JSON.parse (<anonymous>)
    at Request._callback (C:\Users\Anthonny Giroud\Documents\girouda\lbc\node_modules\leboncoin-api\lib\item.js:134:32)
    at Request.self.callback (C:\Users\Anthonny Giroud\Documents\girouda\lbc\node_modules\request\request.js:185:22)
    at emitTwo (events.js:126:13)
    at Request.emit (events.js:214:7)
    at Request.<anonymous> (C:\Users\Anthonny Giroud\Documents\girouda\lbc\node_modules\request\request.js:1161:10)
    at emitOne (events.js:116:13)
    at Request.emit (events.js:211:7)
    at IncomingMessage.<anonymous> (C:\Users\Anthonny Giroud\Documents\girouda\lbc\node_modules\request\request.js:1083:12)
    at Object.onceWrapper (events.js:313:30)
    at emitNone (events.js:111:20)
    at IncomingMessage.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1064:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)

Problem with SetFilters Private - Pro

Hi,

Thanks for the work : the Api looks great ! I have just begun to test it.

I ve got trouble using the Filters to get content only from PROFESSIONEL or PARTICULIER.

It doesn't matter which value I pass through setFilters() : i get the same content (=understand private & pro in the result).

I used the sample code you provide in the readme file.
.setFilter(leboncoin.FILTERS.PARTICULIER) send me back Pro & Private content.

Am I missing something ?

Search not returning results

Hello,

my code using leboncoin-api have started to fail about a week ago, I wonder if there has been an API change:

const leboncoin = require('leboncoin-api');
var search = new leboncoin.Search()
    .setPage(1)
    .setQuery('clavier')
    .setFilter(leboncoin.FILTERS.PARTICULIER)
    .setCategory("instruments_de_musique")
    .setRegion("ile_de_france");

search.run().then(function (data) {
    console.log(data.page); // the current page
    console.log(data.nbResult); // the number of results for this search
    console.log(data.results); // the array of results
}, function (err) {
    console.error(err);
});

returns no results:

PS C:\Users\redacted.r\dev\adsvisor> node .\testlbc.js
1
NaN
[]

I was pretty sure it worked two weeks ago.

When I run the search manually, there are results to this request. Also, when I look at the network, I see the results are fed from a REST API which I think wasn't there before. Has there been a revamp ?

Empty results => example code fail

Hi,
first you should talk about the lodash dependency, had to install manually (Error: Cannot find module 'lodash').
Then when I try the given example from the Readme, I get
(node:12192) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'getDetails' of undefined at C:\...\index.js:23:21
which basically means that I get no data back. Does someone else experience that with the latest version?
Thanks !

Why data.pages * data.nbResult is inferior compared to the equivalent search on lbc website ?

First of all, many thanks for this module. I may tips you a bit in the futur in btc (feel free to give your address) depending on external factor...
Anyway, I got one question :

Does the number of results from search.run() should equals the the normal website's one ?

For instance, given this (location default Toute la France which is what I want):

    const search = new leboncoin.Search()
        .setPage(pageToBrowse)
        .setQuery("1080")
        .setTitleOnly()
        .setFilter(leboncoin.FILTERS.PARTICULIER)
        .setCategory("informatique")
        .addSearchExtra("price", {min: 300, max: 1000})

I got let say 150 results with data.pages * data.nbResult but when using the website I got a superior number.

Screenshot 2019-03-09 at 22 05 52

Is this normal that the api.leboncoin.fr return something different 🤔 ?

Parseseller doesn't work when professional items

Instead of a "title" class it's a "panelTitle" class

You use this code for parseSeller in item.js :
return cleanString($(".mbs > .title").html().trim());

But for professional items (i don't know if it's the case for every the professional item) the html code looks like this :
capture d ecran 2017-09-22 a 13 03 53

Great work by the way ;)

Support for car brands

I tried search with following values:

search.setFilter(leboncoin.FILTERS.ALL)
        .setCategory("voitures")
        .setRegion("ile_de_france")
        .addSearchExtra('brand', ["0", "Bmw"]);

It throws error:

node_modules\leboncoin-api\lib\search.js:248
            searchLabel = searchId[0].value;
                                      ^

TypeError: Cannot read property 'value' of undefined

I think it comes from the "groups" intermediate property in subcategories.json, unless I miss something?

  "2": {
    "brand": {
      "groups": [
        {
          "label": "Marques Courantes",
          "values": [
            {
              "label": "Audi",
              "value": "Audi"
            },
...
        {
          "label": "Autres Marques",
          "values": [
            {
              "label": "Abarth",
              "value": "Abarth"
            },

I think "Marques Courantes" and "Autres Marques" could be merged to solve this.
Otherwise I've made a quickfix, let me know if you want a merge request.

Sample usage

Dear Thomas,
For some reason the usage sample you created does not produce any output for me. I needed to create a .then(function(data) ... to handle the result.
I am not very familiar with promises (more an old style callback person) but are you sure your lib is actually supporting both callbacks and promises ?

Problems with API

I tried to run this script

const leboncoin = require('leboncoin-api');
var search = new leboncoin.Search()
.setPage(1) //ricercare nella pagina
.setQuery('velo') //cosa cercare
.setFilter(leboncoin.FILTERS.PARTICULIER) // PROFESSIONNELS oppure ALL
.setCategory("locations") //categoria di ricerca
.setRegion("alsace") // regione di ricerca
.setDepartment("Bas-rhin")
.setLocation("Colmar")
.addSearchExtra("price", {min: 200, max: 400}) // will add a range of price
//.addSearchExtra('furnished', ["1", "Non meublé"]);

search.run().then(function (data) {
console.log(data.page); // the current page
console.log(data.nbResult); // the number of results for this search
console.log(data.results); // the array of results
}, function (err) {
console.error(err);
});`
but returns always

1 NaN []

That's strange because some days ago it worked well

Cannot extract phone number from image

Hello, first thank you form you api.

There is an issue while parsing the GIF phone number. It raises an error :
Invalid GIF 87a/89a header. I believe it is coming from this line 👍

pixelGif.parse(phoneNumberAddress).then(function(images){

Thanks.

Shared Search Extras

Thanks Thomas for this usefull library.

When creating and running two searchs, I found out the second Search object inherited of searchExtras values from the first one.

This seems to be due to the way searchExtras field is initialized.

Maybe I'm wrong but I suggest not to create searchExtras this way :

Search.prototype.searchExtras = {};

but this way :

const Search = function (options) {
    ...
    this.searchExtras = {};
    ...
}

I think you should do the same for all fields. Putting fields in the prototype is only usefull if you plan to share them between most of your instances (this is mostly what you want for functions but not for data).

Blocked by CORS policy

Hello, merci pour ton repo il est top.

Petit problème survenu depuis peu (je ne serai pas dire exactement quand) mais mes requêtes sont bloquées. Je n'ai pas touché à mon code qui avant fonctionnait :/
Sais-tu d'où cela pourrai venir ? Fortification de l'api leboncoin ?
Merci d'avance :)

(Je suis bien sur la dernière version en 0.0.35

image

addSearchExtra failed with key 'real_estate_type'

Thank you for your work on this project ! That's really great !

I started to work with, using the README.md example file. I modified it a little bit to create a query for "ventes_immobilieres" category. Here is the way it set my request:

var search = new leboncoin.Search() .setPage(1) .setQuery("") .setFilter(leboncoin.FILTERS.PARTICULIER) .setCategory("ventes_immobilieres") .setRegion("provence_alpes_cote_d_azur") .setDepartment("vaucluse") .setArea({"lat": 43.82393, "lng": 5.30872, "radius": 10000}) .addSearchExtra("price", {min: 0, max: 100000}) .addSearchExtra("immo_sell_type", "old") .addSearchExtra("real_estate_type", "1")

I am facing the following issue:
TypeError: search.map is not a function at Search.setRegion.Search.setDepartment.Search.setCategory.search.map (/home/justine/Documents/workspace/node_modules/leboncoin-api/lib/search.js:215:21) at /home/justine/Documents/workspace/node_modules/leboncoin-api/lib/search.js:260:30 at /home/justine/Documents/workspace/node_modules/lodash/lodash.js:4925:15 at baseForOwn (/home/justine/Documents/workspace/node_modules/lodash/lodash.js:2990:24) at /home/justine/Documents/workspace/node_modules/lodash/lodash.js:4894:18 at Function.forEach (/home/justine/Documents/workspace/node_modules/lodash/lodash.js:9368:14) at LodashWrapper.object.(anonymous function) [as forEach] (/home/justine/Documents/workspace/node_modules/lodash/lodash.js:15758:25) at Search.setRegion.Search.setDepartment.Search.setCategory._.forEach (/home/justine/Documents/workspace/node_modules/leboncoin-api/lib/search.js:252:21) at Search.setRegion.Search.setDepartment.Search.setCategory.Search.getBodyParams (/home/justine/Documents/workspace/node_modules/leboncoin-api/lib/search.js:307:22) at Search.setRegion.Search.setDepartment.Search.setCategory.Search.run (/home/justine/Documents/workspace/node_modules/leboncoin-api/lib/search.js:362:51)

I noticed that "immo_sell_type" is not among the constant in /const/subcategories.json, is it normal ? I based my query from the html source code:
"query":{"category":"9","immo_sell_type":"old","locations":"Bonnieux_84480__43.82393_5.30872_6536_10000","price":"min-200000","real_estate_type":"1"}

I think the issue comes from "real_estate_type" key but I am not sure. Thanks for your help !

Simple question

My question will be simple.
Since there aren't much documentation on leboncoin API, I believe their API is made for private usage only. Is this package compliant with leboncoin TOS ? Can it be used on a tierce application ?
Regards,
Florent

A write API?

I'm searched online and I couldn't find any way to create announcements in Leboncoin.
Also it will be nice if we can have a connecter for Shopify to sync the products catalog.

API leboncoin not returning result anymore since 1 week

app.get('/api/leboncoin', (req, res) => {
var search = new leboncoin.Search()
.setPage(1)
.setQuery("106 s16")
// .setFilter(leboncoin.FILTERS.PROFESSIONNELS)
//.setCategory("voitures")
.setRegion("ile_de_france")
.addSearchExtra("mrs", 800) // min rent
.addSearchExtra("mre", 40000); // min rent

    search.run().then(function (data) {
        console.log(data.page); // the current page
        console.log(data.nbResult); // the number of results for this search
        console.log(data.results); // the array of results


         res.send({results: {data}})

        // data.results[0].getDetails().then(function (details) {
        //     res.send({results: {details}})

        //     console.log(details); // the item 0 with more data such as description, all images, author, ...
        // }, function (err) {
        //     console.error(err);
        // });
        // data.results[0].getPhoneNumber().then(function (phoneNumer) {
        //     console.log(phoneNumer); // the phone number of the author if available
        // }, function (err) {
        //     console.error(err); // if the phone number is not available or not parsable (image -> string) 
        // });
    }, function (err) {
        console.error(err);
    });

});

Result on server ->
1
NaN
[]

Result in browser ->
{"results":{"data":{"page":1,"nbResult":null,"results":[]}}}

Crash report

I copied the leboncoin item on which the problem occured for your review :

{ title: 'Ferme equestre',
  category: '',
  link: 'http://www.leboncoin.fr/ventes_immobilieres/906045633.htm?ca=12_s',
  images: 
   [ 'http://img1.leboncoin.fr/images/125/125d5f641229eec318e97529a22cbe4df0258c0c.jpg',
     'http://img2.leboncoin.fr/images/31f/31fe3b95a74c7eb8e7b4bf35b4e4fa9f73a27e37.jpg',
     'http://img3.leboncoin.fr/images/c98/c98624a2abb4d463ca78a116b090136b983156b0.jpg' ],
  location: 'Méréville / Essonne',
  urgent: false,
  price: 550000,
  date: Tue Jan 05 2016 11:19:00 GMT+0100 (CET),
  id: 906045633,
  seller: 'MESNEAU Evelyne',
  priceCurrency: 'EUR',
  city: 'Méréville',
  zip: 91660,
  'type de bien': 'Autre',
  surface: '50 000 m2',
  ges: 'D (de 21 à 35)',
  'classe énergie': 'E (de 231 à 330)',
  description: 'Vends propriété équestre (centre équestre/poney-club) <br>Emplacement <br>20 km d\'Etampes<br>70 km de Paris<br>5.00 ha<br><br>Installations équestres<br>30 boxes<br>Une carrière d\'obstacles de 80 x 80 <br>Une carrière de dressage de 10 x 40 <br>Une carrière poneys (dit Rond d\'Havrincourt) de 28 x 18 <br>Une stabulation poneys de 12 x12 sur un grand paddock de 50 x 30 <br>Une grange de 400 m2 dont un petit manège pour les baby-poneys <br>7 paddocks avec abreuvement sur plus de 3 ha mitoyens à ce corps de ferme<br>un lieu d\'entreposage du fumier sur 2 petites parcelles évitant les contraintes d\'une fosse<br>un club-house<br><br>Bâtiments d\'habitations<br><br>Belle maison de plain-pied entièrement rénovée de 200 m2 comprenant : <br>- grand salon avec cheminée<br>- grande cuisine<br>- 3 chambres<br>- salle de bains (état neuf)<br>- un bureau<br>- à l\'étage, un studio également en parfait état pouvant permettre l\'hébergement d\'un stagiaire<br>Maison de 88 m2 comprenant :<br>- Rez-de-chaussée : salon/salle à manger avec cheminée et cuisine<br>- A l\'étage : Chambre avec salle de bains<br> dépendance sur jardin clos idéal pour couple moniteur/trice<br>Petite maison de 60 m2 avec étage à rénover.' }
Unhandled rejection TypeError: Cannot read property 'Symbol(Symbol.iterator)' of null
    at new Uint8Array (native)
    at /Users/alexandre/leboncoin/node_modules/pixel-util/lib/index.js:45:25
    at tryCatcher (/Users/alexandre/leboncoin/node_modules/bluebird/js/main/util.js:26:23)
    at Promise._settlePromiseFromHandler (/Users/alexandre/leboncoin/node_modules/bluebird/js/main/promise.js:507:31)
    at Promise._settlePromiseAt (/Users/alexandre/leboncoin/node_modules/bluebird/js/main/promise.js:581:18)
    at Promise._settlePromiseAtPostResolution (/Users/alexandre/leboncoin/node_modules/bluebird/js/main/promise.js:245:10)
    at Async._drainQueue (/Users/alexandre/leboncoin/node_modules/bluebird/js/main/async.js:128:12)
    at Async._drainQueues (/Users/alexandre/leboncoin/node_modules/bluebird/js/main/async.js:133:10)
    at Immediate.Async.drainQueues [as _onImmediate] (/Users/alexandre/leboncoin/node_modules/bluebird/js/main/async.js:15:14)
    at processImmediate [as _immediateCallback] (timers.js:383:17)

The calling code (pretty much your sample code actually):

var mysearch = new leboncoin.Search()
        .setPage(1)
        .setQuery("rénover")
        .setFilter(leboncoin.FILTERS.ALL)
        .setCategory("ventes_immobilieres")
        .setRegion("ile_de_france")
        .addSearchExtra("ret", 5)
        .setUrgencyOnly(false)
        .setTitleOnly(false);

mysearch.run().then(function (data) {
    console.log(data.page); // the current page
    console.log(data.nbResult); // the number of results for this search
    console.log(data.results); // the array of results
    data.results[0].getDetails().then(function (details) {
        console.log(details); // the item 0 with more data such as description, all images, author, ...
    }, function (err) {
        console.error(err);
    });
    data.results[0].getPhoneNumber().then(function (phoneNumer) {
        console.log(phoneNumer); // the phone number of the author if available
    }, function (err) {
        console.error(err); // if the phone number is not available or not parsable (image -> string) 
    });
}, function (err) {
    console.error(err);
});

Images are not extracted

Hello,

It seems that only the first picture is extracted for all house/apartments rentals :
http://www.leboncoin.fr/locations/930287312.htm?ca=21_s
Looking at the code:

$(".thumbnails .item_imagePic > img").each(function (index, elem) {
    images.push($(elem).attr('src').replace("thumbs",'images'));
 });

 if(images.length == 0) {
  images.push($(".item_image.big > img").attr('src'));
 }

In the page source there are no such classes.

Bike is not defined

Au lancement du serveur, l'erreur suivante :

/node_modules/leboncoin-api/lib/bike.js:7
Bike = function(ad) {
^
ReferenceError : Bike is not defined
at Object. ( /node_modules/leboncoin-api/lib/bike.js:7)
at Module._compile (module.js:652:10)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)

Pour résoudre ce problème dans mon projet en attendant un FIX j'ai ajouteé un "let" devant "Bike".
J'utilise ExpressJs avec cette libs,
Merci :)

Images not extracted in getDetails

Hi,

When I use your code sample to have details about an item, I have in the result:
images: [ undefined ],

Would you know how it can be fixed?

Search - Set the url

I'm using your JS API for a project. I already have the URLs of leboncoin queries.

What do you think about adding a setUrl() to the Search ?
I just check in getUrl() if an URL is already defined. If it is I return it, if it isn't, I build an URL (initial way).

I can propose a pull request.

Publish typings

I'm working on a simple application using nodejs and your library, therefore I'd like to create it using typescript, in order to do that, i'd need typings of this library.

If you don't know how to create typings, I can do it for you in @types repository but I'll need a list of methods with their signature.

TypeError: Cannot convert undefined or null to object

Bonjour,
Il y a un souci lorsqu'on veut faire une recherche avec un filtre de prix, en sélectionnant une catégorie principale (et non pas une sous-catégorie).

// paramètres
 var search = new leboncoin.Search()
  .setQuery("test")
  .setCategory("8") // immobilier
  search.addSearchExtra("price", { min: 0, max: 5000 })
  var bodyParams = search.getBodyParams();

  // recherche
  var search = new leboncoin.Search()
  search.run(null, bodyParams)

L'erreur étant :

TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at _.forEach (/node_modules/leboncoin-api/lib/search.js:271:26)

Merci

TypeError: Cannot read property 'value' of undefined

Hello

When I try the example provided in main page (https://github.com/tdurieux/leboncoin-api), I have the following error :


C:\lbc\node_modules\leboncoin-api\lib\search.js:235
            searchLabel = searchId[0].value;
                                      ^

TypeError: Cannot read property 'value' of undefined
    at search.map.searchLabel (C:\lbc\node_modules\leboncoin-api\lib\search.js:235:39)
    at Array.map (<anonymous>)
    at getIdsForLabels (C:\lbc\node_modules\leboncoin-api\lib\search.js:232:21)
    at _.forEach (C:\lbc\node_modules\leboncoin-api\lib\search.js:277:30)
    at C:\lbc\node_modules\lodash\lodash.js:4911:15
    at baseForOwn (C:\lbc\node_modules\lodash\lodash.js:2996:24)
    at C:\lbc\node_modules\lodash\lodash.js:4880:18
    at Function.forEach (C:\lbc\node_modules\lodash\lodash.js:9344:14)
    at LodashWrapper.object.(anonymous function) [as forEach] (C:\lbc\node_modules\lodash\lodash.js:15716:25)
    at getSubCategoriesExtras (C:\lbc\node_modules\leboncoin-api\lib\search.js:269:21)
    at Search.getBodyParams (C:\lbc\node_modules\leboncoin-api\lib\search.js:324:22)
    at Search.run (C:\lbc\node_modules\leboncoin-api\lib\search.js:369:51)
    at Object.<anonymous> (C:\lbc\lbc.js:18:8)
    at Module._compile (internal/modules/cjs/loader.js:688:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
    at Module.load (internal/modules/cjs/loader.js:598:32)

Any idea why ?
Thanks for advance.
Sybaris

[Feature] Customize API key

It would be nice to be able to customize API key.

If I add an options argument to the run method, would it suit you ?

url formating in query

Amazing api Thomas, thanks a lot.

I came across the following issue.
Consider the following query :
"rénover OR réhabiliter OR investisseur"
leboncoin will translate it as follows:
q=rénover+OR+réhabiliter+OR+investisseur
Your api will convert it to
q=r%C3%A9nover%20OR%20r%C3%A9habiliter%20OR%20investisseur
and no result will be found.

(trying to pass the + will not help either)
When you have a minute.
Best regards.
Alex

Suggestion for improvement

Thanks a lot Thomas for this convenient API.
You may let us add "raw" query component to address category specific features, like for instance the brand for a car search or many other examples you may find in the numerous categories in Leboncoin.fr
Best regards,
Alex

USE a proxy

I have heard that it is possible to bypass the protection with a proxy provider, is it possible for you to implement this and ask the user to enter their proxy provider (because it is not free)
thank's

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.