Boulanger avatar
Boulanger

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

View all Actors
Boulanger

Boulanger

anchor/boulanger

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

Extract information from boulanlger : 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.boulanger.com/resultats?tr=samsung"
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 = $('.product-item')
23            // const item = $('.rm-product')
24            const itemInfo = item.map(function(i,elem) {
25                let obj = {}
26                obj.title = $(this).find('h2').text()
27                obj.sponsored = false
28                obj.price = $(this).find('.price__amount').text()
29                obj.img = $(this).find('img').attr('src')
30                obj.rank = i+1
31                return obj
32            }).get()
33    
34            const itemSponsored = $('.rm-product')
35            const itemInfoSponsored = itemSponsored.map(function(i,elem) {
36                let obj = {}
37                obj.title = $(this).find('h2').text()
38                obj.sponsored = true
39                obj.price = $(this).find('.rm_price').text()
40                obj.img = $(this).find('img').attr('src')
41                obj.rank = i+1
42                return obj
43            }).get()
44    
45            // return [...itemInfo,...itemInfoSponsored]
46            const allitems = itemInfoSponsored.concat(itemInfo)
47            return allitems
48        })
49        
50        let itemsWithDataProp = items.map(obj => { 
51            for(const key of Object.keys(data) ){
52                obj[key] = data[key]
53            }
54            return obj
55        })
56        return itemsWithDataProp;
57    },
58    "proxyConfiguration": {
59        "useApifyProxy": true,
60        "apifyProxyGroups": [
61            "RESIDENTIAL"
62        ],
63        "apifyProxyCountry": "FR"
64    }
65};
66
67(async () => {
68    // Run the Actor and wait for it to finish
69    const run = await client.actor("anchor/boulanger").call(input);
70
71    // Fetch and print Actor results from the run's dataset (if any)
72    console.log('Results from dataset');
73    const { items } = await client.dataset(run.defaultDatasetId).listItems();
74    items.forEach((item) => {
75        console.dir(item);
76    });
77})();
Developer
Community logoMaintained by Community
Actor metrics
  • 1 monthly users
  • 100.0% runs succeeded
  • Modified 17 days ago

You might also like these Actors