Пример #1
0
        /// <summary>
        /// Get vacancy info
        /// </summary>
        /// <param name="vacancyPage">Vacancy struct with job url and id</param>
        /// <returns>Vacancy struct if specific job post exists</returns>
        private Vacancy GetVacancy(VacancyPageInfo vacancyPage)
        {
            var htmlGet  = new HtmlWeb();
            var htmlPage = htmlGet.Load(vacancyPage.JobURL);

            HtmlNode htmlNode = htmlPage.DocumentNode;

            if (null != htmlNode)
            {
                Vacancy        vacancy = new Vacancy();
                JobParseHelper parser  = new JobParseHelper(htmlNode);

                vacancy.Title           = parser.GetTitle();
                vacancy.Salary          = parser.GetSalary();
                vacancy.Location        = parser.GetLocation();
                vacancy.Experience      = parser.GetExperience();
                vacancy.Description     = parser.GetDescription();
                vacancy.Education       = parser.GetEducation();
                vacancy.PublicationDate = parser.GetCreationDate();
                vacancy.ParseSiteId     = siteId;
                vacancy.VacancyHref     = vacancyPage.JobURL;
                //vacancy.VacancyId = Convert.ToInt32(vacancyPage.JobId);
                vacancy.PhoneNumber = parser.GetPhoneNumber(vacancyPage.JobId);
                return(vacancy);
            }
            else
            {
                return(null);
            }
        }
Пример #2
0
        /// <summary>
        /// Get all job posts and return their links to the job information page
        /// </summary>
        /// <param name="html">Html page of Ria.ua website</param>
        /// <returns>List of references to parse vacancy information</returns>
        private List <VacancyPageInfo> GetJobLinksOnPage(HtmlDocument html)
        {
            if (null != html)
            {
                HtmlNode htmlNode = html.DocumentNode;

                var children = htmlNode
                               .SelectSingleNode("//div[@class='standart-view ']")
                               .ChildNodes;

                List <VacancyPageInfo> jobLinks = new List <VacancyPageInfo>();

                int jobIndex = 0;
                foreach (var child in children)
                {
                    if (child.Name == "div" &&
                        child.Id.Contains("adv_"))
                    {
                        VacancyPageInfo vacancyInfo = new VacancyPageInfo();

                        vacancyInfo.JobId  = child.Id.Substring("adv_".Length);
                        vacancyInfo.JobURL = GetJobLink(child, jobIndex);

                        jobLinks.Add(vacancyInfo);

                        jobIndex++;
                    }
                }

                return(jobLinks);
            }
            else
            {
                throw new Exception("Could not get any vacancies on specific page!");
            }
        }