public ActionResult addDoctorDoctolib(addDoctor addDoctor) { HttpClient Client = new HttpClient(); Client.BaseAddress = new Uri("http://localhost:8089"); Client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage response = Client.GetAsync("Epione-web/rest/doctolib/path/" + addDoctor.path).Result; ViewBag.path = addDoctor.path; ViewBag.email = addDoctor.email; var result = response.Content.ReadAsAsync <IEnumerable <DoctolibDoctor> >().Result; if (response.IsSuccessStatusCode) { DoctolibDoctor doctor = new DoctolibDoctor(); foreach (var d in result) { doctor = d; } doctor.email = addDoctor.email; doctor.password = addDoctor.password; Client.PostAsJsonAsync <DoctolibDoctor>("Epione-web/rest/doctolib/addDoctor", doctor).ContinueWith((postTask) => postTask.Result.EnsureSuccessStatusCode()); ViewBag.status = response.StatusCode; } else { ViewBag.status = "Error"; } return(View()); }
public DoctolibDoctor GetDoctor(string link) { DoctolibDoctor doctolibs = new DoctolibDoctor(); doctolibs = service.getDoctorByPath(link); return(doctolibs); }
//http://localhost:54656/api/doctolib?speciality=&location=&page public IEnumerable <DoctolibDoctor> Get(string speciality, string location, string page) { List <DoctolibDoctor> doctolibs = new List <DoctolibDoctor>(); foreach (var item in service.getListDoctorsBySpecialityAndLocation(speciality, location, page)) { DoctolibDoctor doctolib = new DoctolibDoctor(); doctolib = service.getDoctorByPath(item.path); doctolib.name = item.name; doctolib.img = item.img; doctolib.path = item.path; doctolib.address = item.address; doctolib.speciality = item.speciality; doctolibs.Add(doctolib); } return(doctolibs); }
// GET: Doctolib/Details/5 public ActionResult Details(string path, string adress) { DoctolibViewModel doctolib = new DoctolibViewModel(); DoctolibDoctor doctor = service.getDoctorByPath(path); doctolib.img = doctor.img; doctolib.name = doctor.name; doctolib.address = doctor.address; doctolib.lat = doctor.lat; doctolib.lng = doctor.lng; doctolib.speciality = doctor.speciality; //doctolib.skills.Add(doctor.skills); doctolib.presentationProfession = doctor.presentationProfession; doctolib.Horaires = doctor.horaires; doctolib.address = adress.Replace("'", "'") + " " + doctor.address; ViewBag.lat = doctor.lat; ViewBag.lng = doctor.lng; return(View(doctolib)); }
public ActionResult DetailsDoctor(string id) { ViewBag.id = id; HttpClient Client = new HttpClient(); Client.BaseAddress = new Uri("http://localhost:8089"); Client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage response = Client.GetAsync("Epione-web/rest/doctolib/path/" + id).Result; ViewBag.status = response.StatusCode; var result = response.Content.ReadAsAsync <IEnumerable <DoctolibDoctor> >().Result; DoctolibDoctor doctor = new DoctolibDoctor(); foreach (var d in result) { doctor = d; } ViewBag.doctor = doctor; return(View()); }
//**************************MAP***********************//// public DoctolibDoctor getDoctorByPath(string path) { DoctolibDoctor doctor = new DoctolibDoctor(); List <string> skillsList = new List <string>(); HtmlWeb web = new HtmlWeb(); HtmlDocument doc = web.Load("https://www.doctolib.fr/" + path); var Name = doc.DocumentNode.SelectSingleNode("//h1[@class='dl-profile-header-name']"); var Image = doc.DocumentNode.SelectSingleNode("//div[@class='dl-profile-header-photo']/img[@src]"); HtmlAttribute srcImage = Image.Attributes["src"]; var Adresse = doc.DocumentNode.SelectSingleNode("//div[@class='dl-profile-practice-name']"); var Horaire = doc.DocumentNode.SelectSingleNode("//div[@class='js-opening-hours']"); if (Horaire != null) { HtmlAttribute horaire = Horaire.Attributes["data-props"]; doctor.horaires = horaire.Value.Replace(""", "'"); } var position = doc.DocumentNode.SelectSingleNode("//img[@class='dl-profile-doctor-place-map-img']"); HtmlAttribute mapAttribute = position.Attributes["data-map-modal"]; string LatMap = mapAttribute.Value.Substring(mapAttribute.Value.IndexOf("lat":") + 10, 8); string LongMap = mapAttribute.Value.Substring(mapAttribute.Value.IndexOf("lng":") + 10, 8); // string city = path.IndexOf("/", path.IndexOf("/", 2)+ 1).ToString(); var speciality = doc.DocumentNode.SelectSingleNode("//h2[@class='dl-profile-header-speciality']"); var Formations = doc.DocumentNode.SelectNodes("//div[@class='dl-profile-entry-label']"); if (Formations != null) { var Formation = Formations.ToList(); foreach (var formation in Formation) { skillsList.Add(formation.InnerText.Replace("'", "'")); } } var Skills = doc.DocumentNode.SelectNodes("//div[@class='dl-profile-skill-chip']"); var motifs = doc.DocumentNode.SelectNodes("//div[@class='dl-profile-fee-name']"); var tarifs = doc.DocumentNode.SelectNodes("//div[@class='dl-profile-fee-tag']"); if (Skills != null) { var Skill = Skills.ToList(); doctor.skills = ""; foreach (var skill in Skill) { skillsList.Add(skill.InnerText.Replace("'", "'")); doctor.skills = doctor.skills + "|" + skill.InnerText.Replace("'", "'"); } doctor.skills = doctor.skills.Substring(0); } if (motifs != null) { var motif = motifs.ToList(); doctor.formeJuridique = ""; foreach (var m in motif) { // skillsList.Add(skill.InnerText.Replace("'", "'")); doctor.formeJuridique = doctor.formeJuridique + "|" + m.InnerText.Replace("'", "'"); } var tarif = tarifs.ToList(); doctor.adresseSocialSiege = ""; foreach (var t in tarif) { // skillsList.Add(skill.InnerText.Replace("'", "'")); doctor.adresseSocialSiege = doctor.adresseSocialSiege + "|" + t.InnerText.Replace("'", "'"); } } var presentation = doc.DocumentNode.SelectSingleNode("//div[@class='dl-profile-text js-bio dl-profile-bio']"); var adressDoctor = doc.DocumentNode.SelectSingleNode("/html/body/div[4]/div[2]/div[1]/div[4]/div/div[2]/div[1]/div"); doctor.name = Name.InnerText.Replace("'", "'"); doctor.img = srcImage.Value; if (adressDoctor != null) { doctor.city = adressDoctor.InnerText; } doctor.address = Adresse.InnerText.Replace("'", "'").Replace(""", "'"); doctor.lat = LatMap; doctor.lng = LongMap; doctor.speciality = speciality.InnerText.Replace("'", "'").Replace(""", "'"); // doctor.skills = skillsList; doctor.presentationProfession = presentation.InnerText.Replace("'", "'").Replace(""", "'"); return(doctor); }
public List <DoctolibDoctor> filterListDoctorsBySpecialityAndLocation(string speciality, string location, string availabilities) { List <string> listDisponibility = new List <string>(); List <string> listLinkDoctors = new List <string>(); List <DoctolibDoctor> lst = new List <DoctolibDoctor>(); if (location == null) { location = "france"; } if (speciality == null) { speciality = "medecin-generaliste"; } HtmlWeb web = new HtmlWeb(); HtmlDocument doc; try { doc = web.Load("https://www.doctolib.fr/" + speciality + "/" + location + "?availabilities=" + availabilities); } catch { try { doc = web.Load("https://www.doctolib.fr/" + speciality + "/france?availabilities=" + availabilities); } catch { try { doc = web.Load("https://www.doctolib.fr/medecin-generaliste/france?availabilities=" + availabilities); } catch { doc = web.Load("https://www.doctolib.fr/medecin-generaliste/france"); } } } listDisponibility.Add(DoctolibService.betweenStrings(doc.ParsedText.ToString(), "searchResultIds":[", "],"availabilitiesLimit&")); listDisponibility.Add(DoctolibService.betweenStrings(doc.ParsedText.ToString(), ","specialityId":", ","title":")); listDisponibility.Add(availabilities); String[] searchresult = listDisponibility[0].Split(','); List <DoctolibDoctor> doctors = new List <DoctolibDoctor>(); for (int i = 0; i < searchresult.Length; i++) { var json = new WebClient().DownloadString("https://www.doctolib.fr/search_results/" + searchresult[i] + ".json?search_result_format=json&speciality_id=" + listDisponibility[1] + "&limit=" + listDisponibility[2] + "&availability_filter=true"); string total = DoctolibService.betweenStrings(json, "\"total\":", ",\""); if (total != "0") { string link = DoctolibService.betweenStrings(json, ",\"link\":\"", "\",\""); string address = DoctolibService.betweenStrings(json, ",\"address\":\"", "\",\"") + DoctolibService.betweenStrings(json, ",\"city\":\"", "\",\""); string img = "//res.cloudinary.com/doctolib/image/upload/w_160,h_160,c_fill,g_face/" + DoctolibService.betweenStrings(json, ",\"cloudinary_public_id\":\"", "\",\"") + ".jpg"; string lat = DoctolibService.betweenStrings(json, "\"lat\":", ",\""); string lng = DoctolibService.betweenStrings(json, ",\"lng\":", "},\""); string name = DoctolibService.betweenStrings(json, ",\"name_with_title\":\"", "\",\""); DoctolibDoctor doctor = new DoctolibDoctor() { name = name, img = img, address = address, lat = lat, lng = lng, path = link }; lst.Add(doctor); } } return(lst); }