![Doctolib avatar](https://images.apifyusercontent.com/gzGzpTAdpMxDo0SwvSWFc7k1kglFAiNLnM6qACm8GcA/rs:fill:92:92/aHR0cHM6Ly9hcGlmeS1pbWFnZS11cGxvYWRzLXByb2QuczMuYW1hem9uYXdzLmNvbS9rUVZ2QzhDYmwzNk9taTlJRC9hY2N5c3RoS0E4aWhLWXVyWi1kb2MucG5n.webp)
Doctolib
Try for free
3 days trial then $19.00/month - No credit card required now
View all Actors![Doctolib](https://images.apifyusercontent.com/gzGzpTAdpMxDo0SwvSWFc7k1kglFAiNLnM6qACm8GcA/rs:fill:92:92/aHR0cHM6Ly9hcGlmeS1pbWFnZS11cGxvYWRzLXByb2QuczMuYW1hem9uYXdzLmNvbS9rUVZ2QzhDYmwzNk9taTlJRC9hY2N5c3RoS0E4aWhLWXVyWi1kb2MucG5n.webp)
![Doctolib](https://images.apifyusercontent.com/gzGzpTAdpMxDo0SwvSWFc7k1kglFAiNLnM6qACm8GcA/rs:fill:92:92/aHR0cHM6Ly9hcGlmeS1pbWFnZS11cGxvYWRzLXByb2QuczMuYW1hem9uYXdzLmNvbS9rUVZ2QzhDYmwzNk9taTlJRC9hY2N5c3RoS0E4aWhLWXVyWi1kb2MucG5n.webp)
Doctolib
anchor/doctolib
Try for free
3 days trial then $19.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 more
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
- 3 monthly users
- 3 stars
- 100.0% runs succeeded
- Created in Jul 2022
- Modified 3 months ago
Categories