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 Python 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.

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

Doctolib scraper API in Python

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

Install the apify-client

pip 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