Doctolib avatar
Doctolib
Try for free

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

View all Actors
Doctolib

Doctolib

anchor/doctolib
Try for free

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

Scraping Doctolib is now super easy! Get phones, names, contact, timings and addresses of medics, doctors, hospitals... Best part : you can even customize what info to extract from Doctolib! Don't drown in a sea of searches ! Watch the scrapper do the magic :)

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

1# Set API token
2API_TOKEN=<YOUR_API_TOKEN>
3
4# Prepare Actor input
5cat > input.json <<'EOF'
6{
7  "startUrls": [
8    {
9      "url": "https://www.doctolib.fr/infectiologue/75001-paris"
10    }
11  ],
12  "pageFunction": "async function pageFunction(context) {\n    let data = {}\n    let userData = context.request.userData\n    data.url = context.request.url\n    data.label = userData.label\n    // product here is a reference to a doctor page. Naming is mislieading, my apologies. \n    // it's here because usually I work with marketplaces.\n    if(userData && userData.label === 'product'){   \n        context.log.info('label product.');     \n        // data.img = await context.page.locator('[data-qa-id=adview_spotlight_container] img >> nth=0').getAttribute('src')\n        data.nom = await context.page.locator('#main-content h1').innerText({timeout:6000})\n        try{\n            data.tarif = await context.page.locator('#payment_means').first().innerText({timeout:3000})\n            data.horaire_contact = await context.page.locator('#openings_and_contact').first().innerText({timeout:3000})\n            data.description = await context.page.locator('.dl-profile-bio').first().innerText({timeout:3000})\n            data.specialite = await context.page.locator('.dl-profile-header-speciality').first().innerText({timeout:3000})\n            data.expertise = await context.page.locator('#skills').first().innerText({timeout:3000})        \n            data.phones = await context.getPhones(data.horaire_contact)\n        }catch(e){\n            context.log.info('not found',e);     \n        }        \n        \n    }else{\n        context.log.info('we are not on a doctor page, so a search or pagination page.');\n        // we are looking for \"doctors\" (called \"product\" here) to be queued, let's write it down\n        userData.label = 'product';\n        const elements = context.page.locator('.search-result-card a[href]');\n        const links = await elements.evaluateAll(elems => elems.map(elem => elem.getAttribute('href')));\n        links.forEach(async link => {\n            if(link.startsWith('/')){ link = 'https://www.doctolib.fr' + link }\n            await context.enqueueRequest(link, userData , false);\n        })\n    }\n    context.log.info(`function ended`);\n    delete data.label\n    return data;\n}\n",
13  "pseudoUrls": [
14    {
15      "purl": "https://www.doctolib.fr/[.*]"
16    }
17  ]
18}
19EOF
20
21# Run the Actor using an HTTP API
22# See the full API reference at https://docs.apify.com/api/v2
23curl "https://api.apify.com/v2/acts/anchor~doctolib/runs?token=$API_TOKEN" \
24  -X POST \
25  -d @input.json \
26  -H 'Content-Type: application/json'
Developer
Maintained by Community
Actor metrics
  • 5 monthly users
  • 100.0% runs succeeded
  • 0.9 days response time
  • Created in Jul 2022
  • Modified 8 days ago