internal static string SingleProperty(HtmlNode node, NodeCommandObject cmd)
        {
            string value = string.Empty;
            MethodInfo info = node.GetType().GetMethod(cmd.Commands[0].Operation);
            object[] param = new object[] { cmd.Xpath };

            if (cmd.Commands[0].Property.Equals("Attribute"))
            {
                HtmlNode _nodeFromRoot = (HtmlNode)info.Invoke(node, param);
                value = _nodeFromRoot.Attributes[cmd.Commands[0].Value].Value;
            }
            else
            {
                try
                {
                    HtmlNode _nodeFromRoot = (HtmlNode)info.Invoke(node, param);
                    value = (string)_nodeFromRoot.GetType().GetProperty(cmd.Commands[0].Property).GetValue(_nodeFromRoot, null);
                }
                catch
                {

                }
            }
            return value;
        }
Exemplo n.º 2
0
 public void Initailize()
 {
     Client = new HtmlWeb();
     CurrentCommand = new NodeCommandObject();
     CommandCollection = new List<NodeCommandObject>();
     DomainObjectCollection = new List<Dictionary<string, string>>();
 }
Exemplo n.º 3
0
 public void RetrieveNextCrawlSequence()
 {
     SQLAccess.Clear();
     SQLAccess.Procedure = "NextCrawlSequence";
     var table = SQLAccess.ExecuteProcedure();
     this.CrawlSequence = new CrawlSequenceObject(table.Rows[0]);
     if (!string.IsNullOrEmpty(this.CrawlSequence.SiteUrl))
         CurrentUrl = this.CrawlSequence.SiteUrl;
     if (this.CrawlSequence.InitialNodeCommandId != 0)
         CurrentCommand = new NodeCommandObject(this.CrawlSequence.InitialNodeCommandId);
 }
 public NodeCommandObject(long id)
 {
     SQLAccess.Clear();
     SQLAccess.Procedure = "NodeCommandById";
     SQLAccess.Parameters.Add(@"id", id);
     var table = SQLAccess.ExecuteProcedure();
     if (table.Rows.Count > 0)
     {
         var nodeCommand = new NodeCommandObject(table.Rows[0]);
         this.Id = nodeCommand.Id;
         this.Name = nodeCommand.Name;
         this.Description = nodeCommand.Description;
         this.Xpath = nodeCommand.Xpath;
         this.Commands = nodeCommand.Commands;
     }
 }
        internal static string DualProperty(HtmlNode node, NodeCommandObject cmd)
        {
            string value = string.Empty;
            MethodInfo info = node.GetType().GetMethod(cmd.Commands[0].Operation);
            object[] param = new object[] { cmd.Xpath };
            try
            {
                HtmlNode _nodeFromRoot = (HtmlNode)info.Invoke(node, param);
                var initial = _nodeFromRoot.GetType().GetProperty(cmd.Commands[0].Property).GetValue(_nodeFromRoot);
                value = (string)initial.GetType().GetProperty(cmd.Commands[1].Property).GetValue(initial);
            }
            catch
            {

            }

            return value;
        }