示例#1
0
        public static ScrapTable SelectTableByClass(this GeckoDocument document, String classname, int index = 0)
        {
            ScrapTable   ret        = new ScrapTable();
            GeckoElement element    = document.GetElementsByClassName(classname)[index] as GeckoElement;
            var          collection = element.GetElementsByTagName("TR");

            foreach (var row in collection)
            {
                foreach (var col in row.ChildNodes)
                {
                    if (!(col is GeckoHtmlElement))
                    {
                        continue;
                    }
                    var buffer = col as GeckoHtmlElement;
                    if ("TD".Equals(buffer.TagName) || "TH".Equals(buffer.TagName))
                    {
                        //ret.Set(col.TextContent);
                        //ret.Set((col as GeckoHtmlElement).OuterHtml);
                        ret.Set(col as GeckoHtmlElement);
                    }
                }
                ret.Next();
            }
            return(ret);
        }
示例#2
0
        private static IEnumerable <GeckoElement> FindMatchingSpans(ConfigurableDictionaryNode selectedNode, GeckoElement parent,
                                                                    ConfigurableDictionaryNode topLevelNode, FdoCache cache)
        {
            var elements     = new List <GeckoElement>();
            var desiredClass = CssGenerator.GetClassAttributeForConfig(selectedNode);

            if (ConfiguredXHTMLGenerator.IsCollectionNode(selectedNode, cache))
            {
                desiredClass = CssGenerator.GetClassAttributeForCollectionItem(selectedNode);
            }
            foreach (var span in parent.GetElementsByTagName("span"))
            {
                if (span.GetAttribute("class") != null && span.GetAttribute("class").Split(' ')[0] == desiredClass &&
                    DoesGeckoElementOriginateFromConfigNode(selectedNode, span, topLevelNode))
                {
                    elements.Add(span);
                }
            }
            return(elements);
        }
示例#3
0
        public static ScrapTable SelectTableById(this GeckoDocument document, String id)
        {
            ScrapTable   ret        = new ScrapTable();
            GeckoElement element    = document.GetElementById(id);
            var          collection = element.GetElementsByTagName("TR");

            foreach (var row in collection)
            {
                foreach (var col in row.ChildNodes)
                {
                    if (!(col is GeckoHtmlElement))
                    {
                        continue;
                    }
                    var buffer = col as GeckoHtmlElement;
                    if ("TD".Equals(buffer.TagName) || "TH".Equals(buffer.TagName))
                    {
                        ret.Set(col as GeckoHtmlElement);
                    }
                }
                ret.Next();
            }
            return(ret);
        }
示例#4
0
 public static String GetElementByTagNameToNodeValue(this GeckoElement element, String tag, int index = 0)
 {
     return(element.GetElementsByTagName(tag)[index].FirstChild.NodeValue);
 }
示例#5
0
 public static T GetElementByTagName <T>(this GeckoElement element, String tag, int index = 0) where T : GeckoElement
 {
     return(element.GetElementsByTagName(tag)[index] as T);
 }