Ejemplo n.º 1
0
 protected override string GetVacancyUrl(HtmlAgilityPack.HtmlNode div)
 {
     var vacancyHref = div.Descendants("a").Where(
         d => d.Attributes.Contains("class") && d.Attributes["class"].Value.Contains("vacancy-title"))
         .Select(d => d.Attributes["href"].Value).SingleOrDefault();
     return BaseUrl + vacancyHref;
 }
Ejemplo n.º 2
0
 protected override string GetPosition(HtmlAgilityPack.HtmlNode div)
 {
     return div.Descendants("a").Where(
        d => d.Attributes.Contains("class") &&
        d.Attributes["class"].Value.Contains("rua-b-vacancy-title") || d.Attributes["class"].Value.Contains("jqKeywordHighlight")
        ).Select(d => d.InnerText).First();
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="node"></param>
        /// <param name="element"></param>
        /// <param name="attribute"></param>
        /// <param name="valuePortion"></param>
        /// <returns></returns>
        public static HtmlAgilityPack.HtmlNode GetNode(HtmlAgilityPack.HtmlNode node,
                                            string element,
                                            string attribute,
                                            string valuePortion,
                                            bool tryNull = false)
        {
            if(tryNull)
            {
                try
                {
                    var _nodes = node.Descendants(element)
                            .Where(d => d.Attributes.Contains(attribute) && d.Attributes[attribute].Value.Contains(valuePortion));

                    if(_nodes != null && _nodes.Count() > 0)
                    {
                        var _node = _nodes.ToArray()[0];//.SingleOrDefault();
                        return _node;
                    }
                }
                catch { }
            }
            else
            {
                var _nodes = node.Descendants(element)
                            .Where(d => d.Attributes.Contains(attribute) && d.Attributes[attribute].Value.Contains(valuePortion));

                if(_nodes != null && _nodes.Count() > 0)
                {
                    var _node = _nodes.ToArray()[0];//.SingleOrDefault();
                    return _node;
                }
            }
            return null;
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="node"></param>
 /// <param name="element"></param>
 /// <param name="attribute"></param>
 /// <param name="valuePortion"></param>
 /// <returns></returns>
 public static string GetInnerText(HtmlAgilityPack.HtmlNode node,
                                     string element,
                                     string attribute,
                                     string valuePortion,
                                     string defaultValue = "")
 {
     var _node = node.Descendants(element)
                 .Where(d => d.Attributes.Contains(attribute) && d.Attributes[attribute].Value.Contains(valuePortion))
                 .FirstOrDefault();
     if(_node == null)
         return defaultValue;
     return _node.InnerText;
 }
Ejemplo n.º 5
0
 private IEnumerable<HtmlAgilityPack.HtmlNode> GetItemNodes(HtmlAgilityPack.HtmlNode node)
 {
     var itemscopeAttr = node.GetAttributeItemScope();
     if (itemscopeAttr != null)
     {
         yield return node;
         yield break;
     }
     foreach (var childNode in node.Descendants())
     {
         foreach (var item in GetItemNodes(childNode))
         {
             yield return item;
         }
     }
 }
Ejemplo n.º 6
0
 protected override string GetVacancyUrl(HtmlAgilityPack.HtmlNode row)
 {
     return row.Descendants("td").ElementAt(1).Descendants("a").Single().Attributes["href"].Value;
 }
Ejemplo n.º 7
0
 protected override string GetPosition(HtmlAgilityPack.HtmlNode row)
 {
     return row.Descendants("td").ElementAt(1).Descendants("a").Single().InnerText;
 }
Ejemplo n.º 8
0
 protected override string GetCompany(HtmlAgilityPack.HtmlNode row)
 {
     return row.Descendants("td").ElementAt(2).Descendants("em").Single().InnerText;
 }
 protected override string GetPosition(HtmlAgilityPack.HtmlNode row)
 {
     return row.Descendants("a").Where(
         r => r.Attributes.Contains("class") && r.Attributes["class"].Value.Contains("title"))
         .Select(r => r.InnerText).SingleOrDefault();
 }
Ejemplo n.º 10
0
        private List<VideoInfo> VideosForCategory(HtmlAgilityPack.HtmlNode node)
        {
            List<VideoInfo> videoList = new List<VideoInfo>();

            var sections = node.Descendants("section").Where(s => s.GetAttributeValue("class", "") == "tv");
            if (sections != null)
            {
                foreach (var section in sections)
                {
                    var a = section.SelectSingleNode("a");
                    if (a != null)
                    {
                        VideoInfo video = new VideoInfo();
                        video.VideoUrl = baseUrl + a.GetAttributeValue("href", "");
                        var img = a.Descendants("img");
                        if (img != null && img.First() != null)
                        {
                            video.Thumb = img.First().GetAttributeValue("src", "");
                            video.Title = img.First().GetAttributeValue("alt", "");
                        }
                        var dd = a.Descendants("dd");
                        if (dd != null && dd.FirstOrDefault() != null)
                            video.Length = dd.FirstOrDefault().InnerText;
                        var h1 = a.Descendants("h1");
                        var descP = section.Descendants("p").Where(p => p.GetAttributeValue("class", "") == "ellipsis-lastline");
                        if (descP != null && descP.FirstOrDefault() != null)
                            video.Description = descP.FirstOrDefault().InnerText;
                        if (EnableAOSearch)
                        {
                            SerializableDictionary<string, string> other = new SerializableDictionary<string, string>();
                            var ul = section.SelectSingleNode("div[@class = 'details']/ul[@class = 'keywords']");
                            if (ul != null)
                            {
                                IEnumerable<HtmlNode> keyAs = ul.Descendants("a");
                                foreach (HtmlNode keyA in keyAs)
                                {
                                    other.Add(keyA.GetAttributeValue("data-keyword", ""), keyA.GetAttributeValue("href", ""));
                                }
                            }
                            video.Other = other;
                        }
                        videoList.Add(video);
                    }
                }
            }
            return videoList;
        }
Ejemplo n.º 11
0
 protected override string GetCompany(HtmlAgilityPack.HtmlNode div)
 {
     return div.Descendants("div").Where(
         d => d.Attributes.Contains("class") &&
         d.Attributes["class"].Value.Contains("companyName")).Select(d => d.FirstChild.InnerText).First();
 }
Ejemplo n.º 12
0
 private static string GetVacancyHref(HtmlAgilityPack.HtmlNode div)
 {
     var vacancyHref = div.Descendants("a").Where(
         d => d.Attributes.Contains("class") && d.Attributes["class"].Value.Contains("vacancyDescription"))
         .Select(d => d.Attributes["href"].Value).SingleOrDefault();
     return vacancyHref;
 }
 private void RemoveUnwantedTags(ConfigSection config, HtmlAgilityPack.HtmlNode parentNode)
 {
     if (parentNode != null && config != null && config.RemoveTags != null && config.RemoveTags.Count > 0)
     {
         parentNode.Descendants()
                 .Where(n => config.RemoveTags.Contains(n.Name.ToLowerInvariant()))
                 .ToList()
                 .ForEach(n => n.Remove());
     }
 }
Ejemplo n.º 14
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="node"></param>
 /// <param name="element"></param>
 /// <param name="attribute"></param>
 /// <param name="valuePortion"></param>
 /// <returns></returns>
 public static IEnumerable<HtmlAgilityPack.HtmlNode> GetNodeCollection(HtmlAgilityPack.HtmlNode node,
                                     string element,
                                     string attribute,
                                     string valuePortion)
 {
     var _nodes = node.Descendants(element)
                 .Where(d => d.Attributes.Contains(attribute) && d.Attributes[attribute].Value.Contains(valuePortion));
     return _nodes;
 }
Ejemplo n.º 15
0
        private static NewThreadRequest SetRequestFormInfo(HtmlAgilityPack.HtmlNode root)
        {
            NewThreadRequest data = new NewThreadRequest();
            var formNodes = root.Descendants("input").ToArray();

            var formKeyNode = formNodes
                .Where(node => node.GetAttributeValue("name", "").Equals(THREAD_FORMKEY_KEY))
                .FirstOrDefault();

            var formCookieNode = formNodes
                .Where(node => node.GetAttributeValue("name", "").Equals(THREAD_FORMCOOKIE_KEY))
                .FirstOrDefault();

            try
            {
                data.FormKey = formKeyNode.GetAttributeValue("value", "");
                data.FormCookie = formCookieNode.GetAttributeValue("value", "");
            }
            catch (Exception)
            {
                throw new InvalidOperationException("Could not parse newReply form data.");
            }

            return data;
        }