Leboncoin extractor avatar
Leboncoin extractor

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

View all Actors
Leboncoin extractor

Leboncoin extractor

anchor/leboncoin

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

Extract information from leboncoin.fr : simply provide your search URL (+ your filters and location). You will get the results easy, and fast

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 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').filter(function() { return this.title.match(/[0-9]{5}/);}).text()
28                obj.date = $(this).find('span').filter(function() { return this.title.match(/:/);}).text()
29                obj.img = $(this).find('[data-test-id=adcard-consumer-goods-list] img').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
Community logoMaintained by Community
Actor metrics
  • 13 monthly users
  • 100.0% runs succeeded
  • Modified 9 months ago

You might also like these Actors