Leboncoin extractor avatar
Leboncoin extractor
Try for free

3 days trial then $30.00/month - No credit card required now

View all Actors
Leboncoin extractor

Leboncoin extractor

anchor/leboncoin
Try for free

3 days trial then $30.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

The code examples below show how to run the Actor and get its results. To run the code, you need to have an Apify account. Replace <YOUR_API_TOKEN> in the code with your API token, which you can find under Settings > Integrations in Apify Console. Learn mode

Node.js

Python

curl

1import { ApifyClient } from 'apify-client';
2
3// Initialize the ApifyClient with your Apify API token
4const client = new ApifyClient({
5    token: '<YOUR_API_TOKEN>',
6});
7
8// Prepare Actor input
9const input = {
10    "startUrls": [
11        {
12            "url": "https://www.leboncoin.fr/recherche?category=21&text=mer&price=17-50"
13        }
14    ],
15    "pageFunction": async function pageFunction(context) {
16        let data = {}
17        let userData = context.request.userData
18        data.url = context.request.url
19        data.label = userData.label
20    
21        let items = await context.page.evaluate(() => {
22            const item = $('[data-qa-id=aditem_container]')
23            const itemInfo = item.map(function(i,elem) {
24                let obj = {}
25                obj.title = $(this).find('[data-qa-id=aditem_title]').text()
26                obj.price = $(this).find('[data-test-id=price]').text()
27                obj.location = $(this).find('span[aria-label], p[aria-label]').filter(function() { return this['aria-label']?.match(/[0-9]{5}/);}).text()
28                obj.date = $(this).find('span[aria-label], p[aria-label]').filter(function() { return this.title?.match(/:/);}).text()
29                obj.img = $(this).find('a img:first').attr('src')
30                obj.rank = i+1
31                return obj
32            }).get()
33            return itemInfo
34        })
35        let itemsWithDataProp = items.map(obj => { 
36            for(const key of Object.keys(data) ){
37                obj[key] = data[key]
38            }
39            return obj
40        })
41        return itemsWithDataProp;
42    },
43    "proxyConfiguration": {
44        "useApifyProxy": true,
45        "apifyProxyGroups": [
46            "RESIDENTIAL"
47        ],
48        "apifyProxyCountry": "FR"
49    }
50};
51
52(async () => {
53    // Run the Actor and wait for it to finish
54    const run = await client.actor("anchor/leboncoin").call(input);
55
56    // Fetch and print Actor results from the run's dataset (if any)
57    console.log('Results from dataset');
58    const { items } = await client.dataset(run.defaultDatasetId).listItems();
59    items.forEach((item) => {
60        console.dir(item);
61    });
62})();
Developer
Maintained by Community
Actor metrics
  • 11 monthly users
  • 93.8% runs succeeded
  • 0.0 days response time
  • Created in Oct 2021
  • Modified 4 days ago