private List <UngVien> XuLyCV(XBrowser browser, JobLink job) { job.trang_thai_xu_ly = TrangThaiXuLy.DA_XU_LY; List <UngVien> lst_ung_vien = new List <UngVien>(); try { UngVien ung_vien = new UngVien(); ung_vien.ngay_tao = ung_vien.ngay_sua = XUtil.TimeInEpoch(DateTime.Now); ung_vien.app_id = job.app_id; ung_vien.job_link = job.link; ung_vien.vi_tri = job.ten_job; ThongTinChungUngVien ttuv = new ThongTinChungUngVien(); ttuv.domain = "https://careerbuilder.vn/"; //ttuv.full_text = block_ung_vien.FindElement(By.XPath("//div[@class='Card__root ApplicationCard__root']")).; ung_vien.thong_tin_chung = ttuv; ung_vien.ho_ten = browser.GetInnerText(".//div[@class='act_more']/a/b", 200); ung_vien.link_cv_online = ""; ung_vien.ky_nang = ""; ung_vien.hoc_van = browser.GetInnerText(".//ul[@class='block_info bullet block01']/li[2]/div"); //div[@class='info-list']/ul/li[1] ung_vien.ngay_sinh = 0; ung_vien.so_dien_thoai = browser.GetInnerText(".//ul[@class='block_info block02']/li[1]/div"); ung_vien.email = browser.GetInnerText(".//ul[@class='block_info block02']/li[2]/div"); ung_vien.dia_chi = browser.GetInnerText(".//ul[@class='block_info block02']/li[3]/div"); Uri uri = new Uri(job.link); ung_vien.domain = uri.Host; var id = string.Join("/", job.link.Split('/').Skip(5)); //id = id.Substring(0, id.LastIndexOf('/')); ung_vien.custom_id = id; //Tai file var ifr = browser.FindFirst("//div[@id='tabs-chitiethoso']//iframe"); if (ifr != null) { ung_vien.link_cv_offline = browser.DownloadByBrowserInIFrame("//div[@id='tabs-chitiethoso']//iframe", "//button[@id='download']"); if (!string.IsNullOrEmpty(ung_vien.link_cv_offline)) { ung_vien.cv_byte = File.ReadAllBytes($"{cv_save_path}\\{ung_vien.link_cv_offline}"); } } ung_vien.full_text = browser.GetPageSource(); ung_vien.nguoi_tao = job.nguoi_tao; lst_ung_vien.Add(ung_vien); var count = lst_ung_vien.Count; System.Threading.Thread.Sleep(2000); } catch (Exception ex) { job.trang_thai_xu_ly = TrangThaiXuLy.LOI; job.thong_tin_xu_ly = ex.Message; } job.ngay_xu_ly = XUtil.TimeInEpoch(); return(lst_ung_vien); }
private List <UngVien> XuLyCV(XBrowser browser, JobLink job) { job.trang_thai_xu_ly = TrangThaiXuLy.DA_XU_LY; List <UngVien> lst_ung_vien = new List <UngVien>(); try { var eles_ung_vien = browser.Find("//div[@class='Card__root ApplicationCard__root']"); List <string> lst_block_ung_vien = new List <string>(); if (eles_ung_vien.Count > 0) { foreach (var block_ung_vien in eles_ung_vien) { try { UngVien ung_vien = new UngVien(); ung_vien.ngay_tao = ung_vien.ngay_sua = XUtil.TimeInEpoch(DateTime.Now); ung_vien.app_id = job.app_id; ung_vien.job_link = job.link; ung_vien.vi_tri = job.ten_job; try { ung_vien.ho_ten = block_ung_vien.FindElement(By.ClassName("ApplicationCard__name")).Text; } catch (Exception) { ung_vien.ho_ten = ""; } try { browser.FindFirst(".//div[@class='CardCopy__regularSpacing CardCopy__extraTopMargin']/a").Click(); System.Threading.Thread.Sleep(1500); ung_vien.link_cv_online = block_ung_vien.FindElement(By.XPath(".//iframe[@class='DownloadResume__downloadFrame']")).GetAttribute("src"); } catch (Exception) { } ThongTinChungUngVien ttuv = new ThongTinChungUngVien(); ttuv.domain = "jobstreet.vn"; //ttuv.full_text = block_ung_vien.FindElement(By.XPath("//div[@class='Card__root ApplicationCard__root']")).; ung_vien.thong_tin_chung = ttuv; //Bóc tách XPATH để lấy được thông tin này nếu có var is_exist_email = browser.FindFirst(".//div[@class='ApplicationCard__revealEmailAddress']/span/a"); var is_exist_phone = browser.FindFirst(".//div[@class='ApplicationCard__revealPhoneNumber']/span/a"); if ((is_exist_email != null && is_exist_email.Displayed == true) || (is_exist_phone != null && is_exist_phone.Displayed == true)) { if (is_exist_email != null) { is_exist_email.Click(); System.Threading.Thread.Sleep(300); var element_email = block_ung_vien.FindElement(By.XPath(".//div[@class='ApplicationCard__revealEmailAddress']/a")); if (element_email != null && element_email.Displayed == true) { ung_vien.email = block_ung_vien.FindElement(By.XPath(".//div[@class='ApplicationCard__revealEmailAddress']/a")).Text; } } if (is_exist_phone != null) { is_exist_phone.Click(); System.Threading.Thread.Sleep(300); var element_phone = browser.FindFirst(".//div[@class='ApplicationCard__revealPhoneNumber']/span/a"); if (element_phone != null && element_phone.Displayed == true) { ung_vien.so_dien_thoai = block_ung_vien.FindElement(By.XPath("//div[@class='ApplicationCard__revealPhoneNumber']")).Text; } } } ung_vien.ky_nang = ""; ung_vien.hoc_van = ""; ung_vien.ngay_sinh = 0; Uri uri = new Uri(job.link); ung_vien.domain = uri.Host; var id = string.Join("/", job.link.Split('/').Skip(5)); id = id.Substring(0, id.LastIndexOf('/')); ung_vien.custom_id = id; //Tai file //browser.DownloadByBrowser(block_ung_vien.FindElement(By.XPath(".//div[@class='CardCopy__regularSpacing CardCopy__extraTopMargin']/a"))); var cv_byte = browser.DownloadFile(ung_vien.link_cv_online, out string cv_file_name); if (cv_byte != null) { ung_vien.cv_byte = cv_byte; WriteFile($"{cv_save_path}\\{cv_file_name}", cv_byte); ung_vien.link_cv_offline = cv_file_name; } ung_vien.full_text = browser.GetPageSource(); ung_vien.nguoi_tao = job.nguoi_tao; lst_ung_vien.Add(ung_vien); var count = lst_ung_vien.Count; //browser.FindAndClick("//div[@title='Đóng lại']"); } catch (Exception ex) { Console.WriteLine(ex); } } } else { job.thong_tin_xu_ly = Common.KHONG_TIM_THAY_UNG_VIEN; } } catch (Exception ex) { job.trang_thai_xu_ly = TrangThaiXuLy.LOI; job.thong_tin_xu_ly = ex.Message; } job.ngay_xu_ly = XUtil.TimeInEpoch(); return(lst_ung_vien); }
private List <UngVien> XuLyCV(XBrowser browser, JobLink job) { job.trang_thai_xu_ly = TrangThaiXuLy.DA_XU_LY; List <UngVien> lst_ung_vien = new List <UngVien>(); try { var eles_ung_vien = browser.Find("//div[@class='col-sm-9']//form//div[@class='list-group-item-heading']"); if (eles_ung_vien.Count > 0) { Dictionary <string, string> dic_cv_ung_vien = new Dictionary <string, string>(); foreach (var item_ung_vien in eles_ung_vien) { try { var ho_ten_ele = browser.FindChildElement(item_ung_vien, ".//span[@class='text-accent']"); var link_cv_ele = browser.FindChildElement(item_ung_vien, ".//a"); if (ho_ten_ele != null && link_cv_ele != null) { string href = browser.GetAttribute(link_cv_ele, "href").Trim(); string ho_ten = browser.GetAttribute(ho_ten_ele, "innerText").Trim(); if (!dic_cv_ung_vien.ContainsKey(href)) { dic_cv_ung_vien.Add(href, ho_ten); } } } catch (Exception) { } } foreach (var item in dic_cv_ung_vien) { browser.GoTo(item.Key); UngVien ung_vien = new UngVien(); ung_vien.ngay_tao = ung_vien.ngay_sua = XMedia.XUtil.TimeInEpoch(); ung_vien.app_id = job.app_id; ung_vien.job_link = job.link; ung_vien.ho_ten = item.Value; ung_vien.full_text = browser.GetPageSource(); ung_vien.vi_tri = job.ten_job; ThongTinChungUngVien ttuv = new ThongTinChungUngVien(); ttuv.domain = UrlToDomain(item.Key); ttuv.full_text = browser.GetInnerHtml("//div[@class='resume-show']//div[@class='media']", 200); ttuv.full_text += browser.GetInnerHtml("//div[@id='divResumeContactInformation']", 200); ung_vien.thong_tin_chung = ttuv; //Bóc tách XPATH để lấy được thông tin này nếu có ung_vien.kinh_nghiem = browser.GetInnerHtml("//h4[contains(text(),'Kinh nghiệm')]/following-sibling::dl", 200); ung_vien.ky_nang = ""; ung_vien.hoc_van = browser.GetInnerHtml("//h4[contains(text(),'Học vấn')]/following-sibling::dl", 200); ung_vien.email = browser.GetInnerHtml("//a[contains(@href,'mailto')]", 200); ung_vien.so_dien_thoai = browser.GetInnerHtml("//div[@id='divResumeContactInformation']//dt[contains(text(),'Điện')]/following-sibling::dd[1]", 200); string ngay_sinh = browser.GetInnerText("//span[@class='confidential-birth-day']", 500); ung_vien.domain = UrlToDomain(item.Key); ung_vien.custom_id = item.Key.Substring(item.Key.LastIndexOf("/") + 1); ung_vien.nguoi_tao = job.nguoi_tao; if (!string.IsNullOrEmpty(ngay_sinh)) { //Convert ngay sinh System.Globalization.DateTimeFormatInfo dtfi = new System.Globalization.DateTimeFormatInfo(); dtfi.ShortDatePattern = "dd/MM/yyyy"; dtfi.DateSeparator = "/"; try { var bird_day = Convert.ToDateTime(ngay_sinh, dtfi); ung_vien.ngay_sinh = XMedia.XUtil.TimeInEpoch(bird_day); } catch (Exception) { } } var ifr = browser.FindFirst("//iframe"); if (ifr != null) { ung_vien.link_cv_offline = browser.DownloadByBrowserInIFrame("//iframe", "//button[@id='download']"); if (!string.IsNullOrEmpty(ung_vien.link_cv_offline)) { ung_vien.cv_byte = File.ReadAllBytes($"{cv_save_path}\\{ung_vien.link_cv_offline}"); } } lst_ung_vien.Add(ung_vien); } } else { job.thong_tin_xu_ly = Common.KHONG_TIM_THAY_UNG_VIEN; } } catch (Exception ex) { job.trang_thai_xu_ly = TrangThaiXuLy.LOI; job.thong_tin_xu_ly = ex.Message; } job.ngay_xu_ly = XMedia.XUtil.TimeInEpoch(); return(lst_ung_vien); }