Beispiel #1
0
 /// <summary>
 /// Determines if the value exists in the Meta tag collection of the document
 /// </summary>
 /// <param name="dom">DocumentReader object for the domain</param>
 /// <param name="rule">The rule to match</param>
 /// <returns>True if the rule value is found in the meta tag collection.</returns>
 public bool Process(DOMReader dom, MarketShareRule rule)
 {
     try
     {
         return(dom.ExistsInCollection(dom.MetaTags, rule));
     }
     catch (Exception e)
     {
         ExceptionExtensions.LogWarning(e, "API.MarketAnalysis.Metas.Process()", string.Format("Domain: {0}, {1}", dom.Domain, rule.ToString()));
     }
     return(false);
 }
Beispiel #2
0
 /// <summary>
 /// Determines if the value exists in the Script tag collection of the document
 /// </summary>
 /// <param name="dom">DocumentReader object for the domain</param>
 /// <param name="rule">The rule to match</param>
 /// <returns>True if the rule value is found in the script tag collection.</returns>
 public bool Process(DOMReader dom, MarketShareRule rule)
 {
     try
     {
         foreach (var item in dom.JavascriptTags)
         {
             if (item.Attributes.Contains(rule.Property))
             {
                 string propValue = item.Attributes[rule.Property].Value.ToLower();
                 if (propValue.Contains(rule.Value.ToLower()))
                 {
                     return(true);
                 }
             }
         }
         return(false);
     }
     catch (Exception e)
     {
         ExceptionExtensions.LogWarning(e, "API.MarketAnalysis.Scripts.Process()", string.Format("Domain: {0}, {1}", dom.Domain, rule.ToString()));
     }
     return(false);
 }
Beispiel #3
0
        /// <summary>
        /// Determines if the Generator tag contains the value in the rule
        /// </summary>
        /// <param name="dom">DocumentReader object for the domain</param>
        /// <param name="rule">The rule to match</param>
        /// <returns>True if the rule value is found in the generator tag collection</returns>
        public bool Process(DOMReader dom, MarketShareRule rule)
        {
            try
            {
                foreach (HtmlAgilityPack.HtmlNode node in dom.GeneratorTags)
                {
                    if (!Object.Equals(null, node.Attributes[rule.Property]))
                    {
                        if (node.Attributes[rule.Property].Value.ToLower().Contains(rule.Value.ToLower()))
                        {
                            return(true);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                ExceptionExtensions.LogWarning(e, "API.MarketAnalysis.Generators.Process()", string.Format("Domain: {0}, {1}", dom.Domain, rule.ToString()));
            }

            return(false);
        }
Beispiel #4
0
        /// <summary>
        /// Uses RegEx to determines if the value exists in the text of the document source.
        /// </summary>
        /// <param name="dom">DocumentReader object for the domain</param>
        /// <param name="rule">The rule to match</param>
        /// <returns>True if the rule value is found in the source of the document.</returns>
        public bool Process(DOMReader dom, MarketShareRule rule)
        {
            try
            {
                Regex r = new Regex(rule.Value.Replace("{domain}", "www." + dom.Domain), RegexOptions.IgnoreCase);
                HtmlAgilityPack.HtmlNode source = dom.Document.DocumentNode.SelectSingleNode(rule.Property);

                if (!Object.Equals(null, source))
                {
                    return(r.Match(source.InnerHtml).Success);
                }
            }
            catch (Exception e)
            {
                ExceptionExtensions.LogWarning(e, "API.MarketAnalysis.Text.Process()", string.Format("Domain: {0}, {1}", dom.Domain, rule.ToString()));
            }

            return(false);
        }
Beispiel #5
0
        public bool Process(DOMReader dom, MarketShareRule rule)
        {
            try
            {
                return(dom.Domain.Contains(rule.Value));
            }
            catch (Exception e)
            {
                ExceptionExtensions.LogWarning(e, "API.MarketAnalysis.Urls.Process()", string.Format("Domain: {0}, {1}", dom.Domain, rule.ToString()));
            }

            return(false);
        }