![Leboncoin extractor avatar](https://images.apifyusercontent.com/-ZlrP-4oLfj000AkAJ2SwUslRlWgDW0bw4-0odfku_k/rs:fill:250:250/aHR0cHM6Ly9hcGlmeS1pbWFnZS11cGxvYWRzLXByb2QuczMuYW1hem9uYXdzLmNvbS94a2U4YWtDaWFveU9RbW5GZy90Z3pnYUFOZ01KcndxRUI0Sy02QzVENUMxRS04MEFELTRFRjMtODMyQS1GNkI2RUEyODgyMTkuanBlZw.webp)
Leboncoin extractor
Try for free
3 days trial then $19.00/month - No credit card required now
View all Actors![Leboncoin extractor](https://images.apifyusercontent.com/-ZlrP-4oLfj000AkAJ2SwUslRlWgDW0bw4-0odfku_k/rs:fill:250:250/aHR0cHM6Ly9hcGlmeS1pbWFnZS11cGxvYWRzLXByb2QuczMuYW1hem9uYXdzLmNvbS94a2U4YWtDaWFveU9RbW5GZy90Z3pnYUFOZ01KcndxRUI0Sy02QzVENUMxRS04MEFELTRFRjMtODMyQS1GNkI2RUEyODgyMTkuanBlZw.webp)
![Leboncoin extractor](https://images.apifyusercontent.com/-ZlrP-4oLfj000AkAJ2SwUslRlWgDW0bw4-0odfku_k/rs:fill:250:250/aHR0cHM6Ly9hcGlmeS1pbWFnZS11cGxvYWRzLXByb2QuczMuYW1hem9uYXdzLmNvbS94a2U4YWtDaWFveU9RbW5GZy90Z3pnYUFOZ01KcndxRUI0Sy02QzVENUMxRS04MEFELTRFRjMtODMyQS1GNkI2RUEyODgyMTkuanBlZw.webp)
Leboncoin extractor
anchor/leboncoin
Try for free
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
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 more
1from apify_client import ApifyClient
2
3# Initialize the ApifyClient with your Apify API token
4client = ApifyClient("<YOUR_API_TOKEN>")
5
6# Prepare the Actor input
7run_input = {
8 "startUrls": [{ "url": "https://www.leboncoin.fr/recherche?category=21&text=mer&price=17-50" }],
9 "pageFunction": """async function pageFunction(context) {
10 let data = {}
11 let userData = context.request.userData
12 data.url = context.request.url
13 data.label = userData.label
14
15 let items = await context.page.evaluate(() => {
16 const item = $('[data-qa-id=aditem_container]')
17 const itemInfo = item.map(function(i,elem) {
18 let obj = {}
19 obj.title = $(this).find('[data-qa-id=aditem_title]').text()
20 obj.price = $(this).find('[data-test-id=price]').text()
21 obj.location = $(this).find('span[aria-label], p[aria-label]').filter(function() { return this['aria-label']?.match(/[0-9]{5}/);}).text()
22 obj.date = $(this).find('span[aria-label], p[aria-label]').filter(function() { return this.title?.match(/:/);}).text()
23 obj.img = $(this).find('a img:first').attr('src')
24 obj.rank = i+1
25 return obj
26 }).get()
27 return itemInfo
28 })
29 let itemsWithDataProp = items.map(obj => {
30 for(const key of Object.keys(data) ){
31 obj[key] = data[key]
32 }
33 return obj
34 })
35 return itemsWithDataProp;
36}
37""",
38 "proxyConfiguration": {
39 "useApifyProxy": True,
40 "apifyProxyGroups": ["RESIDENTIAL"],
41 "apifyProxyCountry": "FR",
42 },
43}
44
45# Run the Actor and wait for it to finish
46run = client.actor("anchor/leboncoin").call(run_input=run_input)
47
48# Fetch and print Actor results from the run's dataset (if there are any)
49print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
50for item in client.dataset(run["defaultDatasetId"]).iterate_items():
51 print(item)
52
53# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start
Developer
Maintained by Community
Actor metrics
- 18 monthly users
- 6 stars
- 88.1% runs succeeded
- Created in Oct 2021
- Modified 5 months ago
Categories