Doctolib avatar

Doctolib

Try for free

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

View all Actors
Doctolib

Doctolib

anchor/doctolib
Try for free

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

Scraping Doctolib is now super easy and cheap! Extract phones, names, contact, timings, image and addresses of medics, doctors, hospitals... Best part : you can even customize what info to extract from Doctolib!

You can access the Doctolib programmatically from your own JavaScript applications by using the Apify API. You can also choose the language preference from below. To use the Apify API, you’ll need an Apify account and your API token, found in Integrations settings in Apify Console.

1import { ApifyClient } from 'apify-client';
2
3// Initialize the ApifyClient with your Apify API token
4// Replace the '<YOUR_API_TOKEN>' with your token
5const client = new ApifyClient({
6    token: '<YOUR_API_TOKEN>',
7});
8
9// Prepare Actor input
10const input = {
11    "startUrls": [
12        {
13            "url": "https://www.doctolib.fr/infectiologue/75001-paris"
14        }
15    ],
16    "pageFunction": async function pageFunction(context) {
17    
18        let data = {}
19        let userData = context.request.userData
20        data.url = context.request.url
21        data.label = userData.label
22        
23        if(userData && userData.label === 'doctor'){   
24            data.nom = await context.page.locator('#main-content h1').innerText({timeout:6000})
25            data.tarif = await context.innerTextwrapper(context,'#payment_means')
26            data.horaire_contact = await context.innerTextwrapper(context,'#openings_and_contact')
27            data.description = await context.innerTextwrapper(context,'.dl-profile-bio')
28            data.specialite = await context.innerTextwrapper(context,'.dl-profile-header-speciality')
29            data.expertise = await context.innerTextwrapper(context,'#skills')
30            try{
31                data.phones = await context.getPhones(data.horaire_contact)
32            }catch(e){
33                context.log.info('Phones not found',e);     
34            }
35            try{
36                data.image = await context.page.locator('.dl-profile img').first().getAttribute('src',{timeout:2000})
37                if(data.image.startsWith('/')){ data.image = 'https:' + data.image}
38            }catch(e){
39                context.log.info('Image not found',e);     
40            }        
41            
42        }else{
43            context.log.info('we are not on a doctor page: so a search or pagination page.');
44            userData.label = 'doctor';
45            const elements = context.page.locator('.search-result-card a[href]');
46            const links = await elements.evaluateAll(elems => elems.map(elem => elem.getAttribute('href')));
47            let extenstion = 'fr'
48            if(context.request.url.includes('doctolib.de')){ extenstion = 'de' }
49            if(context.request.url.includes('doctolib.it')){ extenstion = 'it' }
50            links.forEach(async link => {
51                if(link.startsWith('/')){ link = `https://www.doctolib.${extenstion}${link}` }
52                await context.enqueueRequest(link, userData , true);
53            })
54    
55        }
56        context.log.info(`ending this page now`);
57        delete data.label
58        return data;
59    }
60};
61
62// Run the Actor and wait for it to finish
63const run = await client.actor("anchor/doctolib").call(input);
64
65// Fetch and print Actor results from the run's dataset (if any)
66console.log('Results from dataset');
67console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
68const { items } = await client.dataset(run.defaultDatasetId).listItems();
69items.forEach((item) => {
70    console.dir(item);
71});
72
73// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

Doctolib scraper API in JavaScript

The Apify API client for JavaScript is the official library that allows you to use Doctolib API in JavaScript or TypeScript, providing convenience functions and automatic retries on errors.

Install the apify-client

npm install apify-client

Other API clients include:

Developer
Maintained by Community
Actor metrics
  • 10 monthly users
  • 4 stars
  • 89.8% runs succeeded
  • 7.6 hours response time
  • Created in Jul 2022
  • Modified 18 days ago