tdurieux / leboncoin-api

DEPRECATED
https://www.npmjs.com/package/leboncoin-api
169 stars 54 forks source link

Problems with API #28

Closed andreaangeli closed 4 years ago

andreaangeli commented 6 years ago

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

tdurieux commented 6 years ago

which version of the API do you use?

RodolpheGohard commented 6 years ago

same here, using leboncoin-api@0.0.20

tdurieux commented 6 years ago

Leboncoin changed its website, this version does not work anymore. You have to use the latest one.

andreaangeli commented 6 years ago

sorry, I got wrong I updated the module and it works. By the way is there any command to download the results of the research in a formatted json file or CSV ? For instance I tried with the command node research.js > output.json and effectively it returns a file called output.json with the results but probably, the file is not properly formatted because I'm not able to open it as a json file.

grandemk commented 5 years ago

@andreaangeli Use console.log(JSON.stringify(data.results)); console.log alone doesn't format the result in json.