Boulanger avatar
Boulanger
Deprecated
View all Actors
This Actor is deprecated

This Actor is unavailable because the developer has decided to deprecate it. Would you like to try a similar Actor instead?

See alternative Actors
Boulanger

Boulanger

anchor/boulanger

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 more

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.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    console.log(`๐Ÿ’พ Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
74    const { items } = await client.dataset(run.defaultDatasetId).listItems();
75    items.forEach((item) => {
76        console.dir(item);
77    });
78})();
79
80// ๐Ÿ“š Want to learn more ๐Ÿ“–? Go to โ†’ https://docs.apify.com/api/client/js/docs
Developer
Maintained by Community