Leboncoin.fr HTTP client
This package allows to perform requests on the french e-commerce website "leboncoin.fr". At the moment, it contains 3 simple methods for retrieve items data from the website : search(), get() and watch().
Installation
npm install leboncoin-client
Usage examples
Perform a search :
const lbc = ; const req = category: 'informatique' type: 'offres' region_or_department: 'cantal' sellers: 'particuliers' query: 'ordinateur' sort: 'date' titles_only: false urgent_only: false; lbc // browse pages 1 to 5;
Second search example :
const lbc = ; const req = category: 'informatique' city_or_postal_code: '75001' filters: 'Prix min': 400 'Prix max': 'Plus de 1000' ; lbc // only the first page;
Get data from a specific advertisement :
const lbc = ; lbc;
Watch new objects from a specific category and location :
const lbc = ; const req = category: 'informatique' region_or_department: 'gers'; lbc;
Methods
search(request, minPage, maxPage)
Query a research of items specified by various criterias. Return a promise with an array of items in parameter.
Parameter | Type | Description | Default value |
---|---|---|---|
request | object | object containing the query parameters (see request spec for more info) | {} |
minPage | integer | first page to browse | 1 |
maxPage | integer | last page to browse | 1 |
get(id)
Get specific item data by its id. Return a promise with the item data in parameter.
Parameter | Type | Description | Default value |
---|---|---|---|
id | integer | 10-digit item id | required |
watch(request, interval, action)
Watching loop for detect new objects added specified by various criterias. Each time a new object is spotted, the function "action" is called with its data in parameter.
Parameter | Type | Description | Default value |
---|---|---|---|
request | object | object containing the query parameters (see request spec for more info) | {} |
interval | integer | number of seconds between each request | 60 |
action | function | action to execute for process the new object data | required |
Request spec
Field | Type | Description | Default value |
---|---|---|---|
category | string | category to look in (check out the parameters.json for the complete list of categories) | "tous" |
type | string | type of advertisement ("offres" or "demandes") | "offres" |
region_or_department | string | region or department of items (check out the parameters.json for the complete list of locations) | "toute la France" |
city_or_postal_code | string | city or postal code of items (return empty array if it does not exist) | none |
sellers | string | type of sellers ("tous" or "particuliers" or "professionnels" | "tous" |
query | string | matching keywords | none |
sort | string | sort criteria ("date" or "prix") | "date" |
titles_only | boolean | search only in ad titles | false |
urgent_only | boolean | search only for urgent ads | false |
filters: | object | object containing some filters depending on the category (check out the parameters.json for the complete list of filters) | {} |
Filters not implemented yet :
- Car models (depending on the brand)
- Dates ("holidays" categories)
- Clothes sizes (depending on the gender)
Feel free to contact me for any suggestion, issue, improvement...