Ejemplo n.º 1
0
        private void CreateRawler()
        {
            Tool.Data data = new Tool.Data();
            root.Rawler = data;
            Tool.Page page = new Tool.Page();
            data.AddChildren(page);
            page.Url = "http://www.imdb.com/search/name?star_sign=aquarius&sort=starmeter,asc";
            //   page.Url = "http://www.imdb.com/search/name?sort=starmeter,asc&star_sign=aquarius&start=10251";
            page.Comment = "一覧ページ読み込み";



            Tool.TagExtraction tag1 = new Tool.TagExtraction();
            tag1.Tag             = "table";
            tag1.ParameterFilter = "class=\"results\"";
            page.AddChildren(tag1);
            Tool.TagExtraction tag2 = new Tool.TagExtraction();
            tag2.Tag             = "tr";
            tag2.IsMulti         = true;
            tag2.ParameterFilter = "detailed";
            tag1.AddChildren(tag2);
            Tool.Link link = new Tool.Link();
            link.UseAbsolutetLink = true;
            link.UrlFilter        = "/name/";
            link.VisbleType       = Tool.LinkVisbleType.Url;
            tag2.AddChildren(link);

            Tool.Page page1 = new Tool.Page();
            link.AddChildren(page1);
            //飛んだ先のページ

            Tool.TagExtraction tag3 = new Tool.TagExtraction();
            page1.AddChildren(tag3);


            tag3.Tag             = "table";
            tag3.ParameterFilter = "id=\"name-overview-widget-layout\"";

            Tool.ClipText clipText1 = new Tool.ClipText();
            tag3.AddChildren(clipText1);
            clipText1.StartClip = "<h1 class=\"header\">";
            clipText1.EndClip   = "</h1>";
            Tool.DataWrite write2 = new Tool.DataWrite();
            clipText1.AddChildren(new Tool.DataWrite("Name"));
            clipText1.AddChildren(new Tool.Report("Person:", ""));
            Tool.ClipText clip2 = new Tool.ClipText("<div class=\"infobar\">", "</div>");
            tag3.AddChildren(clip2);

            Tool.Link link2 = new Tool.Link();
            clip2.AddChildren(link2);
            link2.VisbleType = Tool.LinkVisbleType.Label;
            link2.IsMulti    = true;
            link2.AddChildren(new Tool.DataWrite("role"));

            Tool.ClipText clip3 = new Tool.ClipText("<div class=\"txt-block\">", "</div>");
            clip3.IsMulti = true;
            tag3.AddChildren(clip3);
            Tool.Contains contains1 = new Tool.Contains("<h4 class=\"inline\">Born:</h4>");
            clip3.AddChildren(contains1);

            Tool.Link link3 = new Tool.Link("/search/name?birth_year", "", false);
            link3.VisbleType = Tool.LinkVisbleType.Label;
            link3.AddChildren(new Tool.DataWrite("born-year"));

            Tool.Link link4 = new Tool.Link("/date/", "", false);
            link4.VisbleType = Tool.LinkVisbleType.Label;
            link4.AddChildren(new Tool.DataWrite("born-date"));

            Tool.Link link5 = new Tool.Link("/search/name?birth_place=", "", false);
            link5.VisbleType = Tool.LinkVisbleType.Label;
            link5.AddChildren(new Tool.DataWrite("born-place"));

            contains1.AddChildren(link3);
            contains1.AddChildren(link4);
            contains1.AddChildren(link5);
            page1.AddChildren(new Tool.NextDataRow());



            //Tool.DataWrite write1 = new Tool.DataWrite();
            //link.AddChildren(write1);
            //Tool.NextDataRow nextData = new Tool.NextDataRow();
            //write1.AddChildren(nextData);


            Tool.Link nLink = new Tool.Link();
            nLink.UrlFilter        = "search/name?";
            nLink.LabelFilter      = "Next";
            nLink.UseAbsolutetLink = true;
            page.AddChildren(nLink);
            Tool.NextPage nextPage = new Tool.NextPage();
            nLink.AddChildren(nextPage);



//            MyLib.ObjectLib.SaveToBinaryFile(data, "data.xml");
            // MyLib.ObjectLib.SaveXML(data, data.GetType(), "data.xml");
            //textBox1.Text = MyLib.IO.TextFileRead("data.xml", Encoding.UTF8);
        }
Ejemplo n.º 2
0
        private void CreateRawler()
        {
            Tool.Data data = new Tool.Data();
            root.Rawler = data;
            Tool.Page page = new Tool.Page();
            data.AddChildren(page);
            page.Url = "http://www.imdb.com/search/name?star_sign=aquarius&sort=starmeter,asc";
             //   page.Url = "http://www.imdb.com/search/name?sort=starmeter,asc&star_sign=aquarius&start=10251";
            page.Comment = "一覧ページ読み込み";

            Tool.TagExtraction tag1 = new Tool.TagExtraction();
            tag1.Tag = "table";
            tag1.ParameterFilter = "class=\"results\"";
            page.AddChildren(tag1);
            Tool.TagExtraction tag2 = new Tool.TagExtraction();
            tag2.Tag = "tr";
            tag2.IsMulti = true;
            tag2.ParameterFilter = "detailed";
            tag1.AddChildren(tag2);
            Tool.Link link = new Tool.Link();
            link.UseAbsolutetLink = true;
            link.UrlFilter = "/name/";
            link.VisbleType = Tool.LinkVisbleType.Url;
            tag2.AddChildren(link);

            Tool.Page page1 = new Tool.Page();
            link.AddChildren(page1);
            //飛んだ先のページ

            Tool.TagExtraction tag3 = new Tool.TagExtraction();
            page1.AddChildren(tag3);

            tag3.Tag = "table";
            tag3.ParameterFilter = "id=\"name-overview-widget-layout\"";

            Tool.ClipText clipText1 = new Tool.ClipText();
            tag3.AddChildren(clipText1);
            clipText1.StartClip = "<h1 class=\"header\">";
            clipText1.EndClip = "</h1>";
            Tool.DataWrite write2 = new Tool.DataWrite();
            clipText1.AddChildren(new Tool.DataWrite("Name"));
            clipText1.AddChildren(new Tool.Report("Person:", ""));
            Tool.ClipText clip2 = new Tool.ClipText("<div class=\"infobar\">", "</div>");
            tag3.AddChildren(clip2);

            Tool.Link link2 = new Tool.Link();
            clip2.AddChildren(link2);
            link2.VisbleType = Tool.LinkVisbleType.Label;
            link2.IsMulti = true;
            link2.AddChildren(new Tool.DataWrite("role"));

            Tool.ClipText clip3 = new Tool.ClipText("<div class=\"txt-block\">", "</div>");
            clip3.IsMulti = true;
            tag3.AddChildren(clip3);
            Tool.Contains contains1 = new Tool.Contains("<h4 class=\"inline\">Born:</h4>");
            clip3.AddChildren(contains1);

            Tool.Link link3 = new Tool.Link("/search/name?birth_year", "", false);
            link3.VisbleType = Tool.LinkVisbleType.Label;
            link3.AddChildren(new Tool.DataWrite("born-year"));

            Tool.Link link4 = new Tool.Link("/date/", "", false);
            link4.VisbleType = Tool.LinkVisbleType.Label;
            link4.AddChildren(new Tool.DataWrite("born-date"));

            Tool.Link link5 = new Tool.Link("/search/name?birth_place=", "", false);
            link5.VisbleType = Tool.LinkVisbleType.Label;
            link5.AddChildren(new Tool.DataWrite("born-place"));

            contains1.AddChildren(link3);
            contains1.AddChildren(link4);
            contains1.AddChildren(link5);
            page1.AddChildren(new Tool.NextDataRow());

            //Tool.DataWrite write1 = new Tool.DataWrite();
            //link.AddChildren(write1);
            //Tool.NextDataRow nextData = new Tool.NextDataRow();
            //write1.AddChildren(nextData);

            Tool.Link nLink = new Tool.Link();
            nLink.UrlFilter = "search/name?";
            nLink.LabelFilter = "Next";
            nLink.UseAbsolutetLink = true;
            page.AddChildren(nLink);
            Tool.NextPage nextPage = new Tool.NextPage();
            nLink.AddChildren(nextPage);

            //            MyLib.ObjectLib.SaveToBinaryFile(data, "data.xml");
               // MyLib.ObjectLib.SaveXML(data, data.GetType(), "data.xml");
            //textBox1.Text = MyLib.IO.TextFileRead("data.xml", Encoding.UTF8);
        }