Collaborama About Help Contact Anonymous [login] Source: site.view [edit] Function name: searchZocDocAppointments Arguments: specialty,zip,insurancePlan,insuranceCarrier,gender,language,children Description: Page type: webl Render function: Module: sandbox Page source: var getDivByClass = fun(P, elt, className) var E = Elem(P, "div") inside elt; every d in E do var c = d.class ? nil; if (c == className) then return d end end; return nil end; var getTimeData = fun(s) var ss = `search_app.response = {`; var i = Str_IndexOf(ss, s); if i > 0 then s = Select(s, i + Size(ss)-1, Size(s)) end; i = Str_IndexOf(`if (ids.length > 0)`, s); if (i > 0) then s = Str_Trim(Select(s, 0, i-1)); if (Str_EndsWith(s, ";")) then s = Select(s, 0, Size(s)-1); end end; s; end; var name = "-1"; if Size(OPTIONALARGS) > 0 then name = OPTIONALARGS[0] end; var res = []; var pageText = Pretty(WubCall("sandbox.callZocDocGetJSON", [specialty, zip, insurancePlan, insuranceCarrier, gender, language, children, name])); pageText = Wub_ReplaceAll(pageText, "\n", " "); pageText = Wub_ReplaceAll(pageText, "\r", " "); pageText = Wub_ReplaceAll(pageText, "\t", " "); var P = NewPage(pageText, "text/html"); var E = Elem(P, "div"); every d in E do var c = d.class ? nil; if (c == "js-prof-row-container sg-row ch-prof-row-container ") then var drInfo = [. .]; var nm = getDivByClass(P, d, "js-search-prof-row-clickable ch-prof-row-photo-container"); if (nm != nil) then var img = Elem(P, "img") inside nm; if Size(img) > 0 then drInfo.photo := img[0].src; end; end; nm = getDivByClass(P, d, "js-search-prof-row-doc-name"); if (nm != nil) then var a = Elem(P, "a") inside nm; var cleanName; if Size(a) > 0 then cleanName = Str_Trim(Text(a[0])); else cleanName = Str_Trim(Text(nm)); end; var span = Elem(P, "span") inside nm; if Size(span) > 0 then drInfo.title := Str_Trim(Text(span[0])); cleanName = Str_Trim(Select(cleanName, 0, Size(cleanName) - Size(drInfo.title))); end; if (Str_EndsWith(cleanName, ",")) then cleanName = Select(cleanName, 0, Size(cleanName) - 1); end; drInfo.name := cleanName; end; nm = getDivByClass(P, d, "ch-prof-row-info-para js-search-prof-row-address"); if (nm != nil) then var addr = Str_Match(Str_Trim(Text(nm)), `(.+),(.+),\s+(\w+)\s+(\d+).+`); if (addr != nil) then drInfo.street := addr[1]; drInfo.city := addr[2]; drInfo.state := addr[3]; drInfo.zip := addr[4] end end; nm = getDivByClass(P, d, "ch-prof-row-speciality sg-title "); if (nm != nil) then drInfo.specialty := Str_Trim(Text(nm)); drInfo.specialtyCode := nm["data-spectialty"] end; nm = getDivByClass(P, d, "js-search-prof-row-doc-name"); if (nm != nil) then var a = Elem(P, "a") inside nm; if Size(a) > 0 then drInfo.profileLink := a[0].href; end; end; nm = getDivByClass(P, d, "insuranceBody"); if (nm != nil) then drInfo.insurance := Str_Trim(Text(nm)); end; nm = getDivByClass(P, d, "ch-prof-row-rating"); if (nm != nil) then every rd in Elem(P, "div") inside nm do c = rd.class ? nil; if Str_IndexOf("sg-rating-small-", c) >= 0 then c = Str_Trim(c); c = Select(c, Size(c)-3, Size(c)-2) + "." + Select(c, Size(c)-1, Size(c)); drInfo.rating := c; end; end; end; nm = getDivByClass(P, d, "js-comment-text ch-prof-row-comment sg-para4 "); if (nm != nil) then var txt = Wub_ReplaceAll(Str_Trim(Text(nm)), `"`, "'"); txt = Wub_ReplaceAll(txt, "\n", " "); if (Str_StartsWith(txt, "'")) then txt = Select(txt, 1, Size(txt)); end; if (Str_EndsWith(txt, "'")) then txt = Select(txt, 0, Size(txt)-1); end; drInfo.review := txt end; res = res + [drInfo] end end; NewPage(`{ "pageData": ` + WubCall("toJSON", [res]) + `,"timeData":` + getTimeData(pageText) + "}", "text/plain");