示例#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
        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);
        }