$API_TOKEN=<YOUR_API_TOKEN>
$cat > input.json << 'EOF'
<{
< "startUrls": [
< {
< "url": "https://www.doctolib.fr/infectiologue/75001-paris"
< }
< ],
< "pageFunction": "async function pageFunction(context) {\n\n let data = {}\n let userData = context.request.userData\n data.url = context.request.url\n\n const isDoctorProfile = userData && userData.label === 'doctor'\n let isProbablyDoctorProfile\n if(!isDoctorProfile){\n isProbablyDoctorProfile = await context.innerTextwrapper(context,'body.profiles, body.online_booking-drafts')\n }\n const isDoctorPage = isDoctorProfile || isProbablyDoctorProfile\n\n data.isDoctorPage = isDoctorPage\n \n if(isDoctorPage){\n context.log.info(`Doctor page ${isDoctorProfile ? 'from search' : '' } ${isProbablyDoctorProfile ? 'guessing' : '' }`);\n data.nom = await context.page.locator('#main-content h1').innerText({timeout:6000})\n data.tarif = await context.innerTextwrapper(context,'#payment_means')\n data.horaire_contact = await context.innerTextwrapper(context,'#openings_and_contact')\n data.description = await context.innerTextwrapper(context,'.dl-profile-bio')\n data.specialite = await context.innerTextwrapper(context,'.dl-profile-header-speciality')\n data.expertise = await context.innerTextwrapper(context,'#skills')\n try{\n data.website = await context.page.locator('.dl-profile-row-section div', { hasText: 'Website' }).locator('a').getAttribute('href',{timeout:2000})\n }catch(e){\n context.log.info('Website not found',e); \n }\n\n try{\n data.phones = await context.getPhones(data.horaire_contact)\n }catch(e){\n context.log.info('Phones not found',e); \n }\n try{\n data.image = await context.page.locator('.dl-profile img').first().getAttribute('src',{timeout:2000})\n if(data.image.startsWith('/')){ data.image = 'https:' + data.image}\n }catch(e){\n context.log.info('Image not found',e); \n } \n }else{\n context.log.info('we are not on a doctor page: so a search or pagination page.');\n data.message = 'you can remove these rows in the settings with \"hideSearchPages\" '\n userData.label = 'doctor';\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 let extenstion = 'fr'\n if(context.request.url.includes('doctolib.de')){ extenstion = 'de' }\n if(context.request.url.includes('doctolib.it')){ extenstion = 'it' }\n links.forEach(async link => {\n if(link.startsWith('/')){ link = `https://www.doctolib.${extenstion}${link}` }\n await context.enqueueRequest(link, userData , true);\n })\n\n }\n context.log.info(`ending this page now`);\n\n return data;\n}\n"
<}
<EOF
$curl "https://api.apify.com/v2/acts/anchor~doctolib/runs?token=$API_TOKEN" \
< -X POST \
< -d @input.json \
< -H 'Content-Type: application/json'