Leboncoin extractor
3 days trial then $19.00/month - No credit card required now
Leboncoin extractor
3 days trial then $19.00/month - No credit card required now
Extract information from leboncoin.fr : no limitation, you get fast results in CSV, Excel... or API format. Le meilleur outil de scrapping pour leboncoin
You can access the Leboncoin extractor programmatically from your own JavaScript applications by using the Apify API. You can also choose the language preference from below. To use the Apify API, you’ll need an Apify account and your API token, found in Integrations settings in Apify Console.
1import { ApifyClient } from 'apify-client';
2
3// Initialize the ApifyClient with your Apify API token
4// Replace the '<YOUR_API_TOKEN>' with your token
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9// Prepare Actor input
10const input = {
11 "startUrls": [
12 {
13 "url": "https://www.leboncoin.fr/recherche?category=21&text=mer&price=17-50"
14 }
15 ],
16 "pageFunction": async function pageFunction(context) {
17 let data = {}
18 let userData = context.request.userData
19 data.url = context.request.url
20 data.label = userData.label
21
22 let items = await context.page.evaluate(() => {
23 const item = $('[data-qa-id=aditem_container]')
24 const itemInfo = item.map(function(i,elem) {
25 let obj = {}
26 obj.title = $(this).find('[data-qa-id=aditem_title]').text()
27 obj.price = $(this).find('[data-test-id=price]').text()
28 obj.location = $(this).find('span[aria-label], p[aria-label]').filter(function() { return this['aria-label']?.match(/[0-9]{5}/);}).text()
29 obj.date = $(this).find('span[aria-label], p[aria-label]').filter(function() { return this.title?.match(/:/);}).text()
30 obj.img = $(this).find('a img:first').attr('src')
31 obj.rank = i+1
32 return obj
33 }).get()
34 return itemInfo
35 })
36 let itemsWithDataProp = items.map(obj => {
37 for(const key of Object.keys(data) ){
38 obj[key] = data[key]
39 }
40 return obj
41 })
42 return itemsWithDataProp;
43 },
44 "proxyConfiguration": {
45 "useApifyProxy": true,
46 "apifyProxyGroups": [
47 "RESIDENTIAL"
48 ],
49 "apifyProxyCountry": "FR"
50 }
51};
52
53// Run the Actor and wait for it to finish
54const run = await client.actor("anchor/leboncoin").call(input);
55
56// Fetch and print Actor results from the run's dataset (if any)
57console.log('Results from dataset');
58console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
59const { items } = await client.dataset(run.defaultDatasetId).listItems();
60items.forEach((item) => {
61 console.dir(item);
62});
63
64// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs
Leboncoin Extractor API in JavaScript
The Apify API client for JavaScript is the official library that allows you to use Leboncoin extractor API in JavaScript or TypeScript, providing convenience functions and automatic retries on errors.
Install the apify-client
npm install apify-client
Other API clients include:
Actor Metrics
11 monthly users
-
6 stars
>99% runs succeeded
Created in Oct 2021
Modified a month ago