Ejemplo n.º 1
0
 public MainWindow()
 {
     InitializeComponent();
     ReportManage.ErrReportEvent += new EventHandler<ReportEvnetArgs>(ReportManage_ErrReportEvent);
     ReportManage.ReportEvnet += new EventHandler<ReportEvnetArgs>(ReportManage_ReportEvnet);
     ReportManage.ChangeRowCount += new EventHandler<EventArgs>(ReportManage_ChangeRowCount);
     ReportManage.StockReport = false;
     init();
     System.Xaml.XamlSchemaContext x = new System.Xaml.XamlSchemaContext();
     var tmp = new Rawler.Tool.Data();
     tmp.Children.Add(new Rawler.Tool.Page());
     rawlerView1.SetRawler(tmp );
     this.Closed += (o, e) => { Dispose(); };
     RawlerView.ViewTask.UISyncContext = System.Threading.Tasks.TaskScheduler.FromCurrentSynchronizationContext();
 }
Ejemplo n.º 2
0
        public MainWindow()
        {
            InitializeComponent();
            ReportManage.ErrReportEvent += new EventHandler <ReportEvnetArgs>(ReportManage_ErrReportEvent);
            ReportManage.ReportEvnet    += new EventHandler <ReportEvnetArgs>(ReportManage_ReportEvnet);
            ReportManage.ChangeRowCount += new EventHandler <EventArgs>(ReportManage_ChangeRowCount);
            ReportManage.StockReport     = false;
            init();
            System.Xaml.XamlSchemaContext x = new System.Xaml.XamlSchemaContext();
            var tmp = new Rawler.Tool.Data();

            tmp.Children.Add(new Rawler.Tool.Page());
            rawlerView1.SetRawler(tmp);
            this.Closed += (o, e) => { Dispose(); };
            RawlerView.ViewTask.UISyncContext = System.Threading.Tasks.TaskScheduler.FromCurrentSynchronizationContext();
        }
Ejemplo n.º 3
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.º 4
0
        //public new void Run()
        //{
        //    Run(true);
        //}

        /// <summary>
        /// 実行
        /// </summary>
        /// <param name="runChildren"></param>
        public override void Run(bool runChildren)
        {
            string txt = string.Empty;

            if (Value == null || Value.Length == 0)
            {
                txt = GetText();
            }
            else
            {
                txt = Value.Convert(this);
            }
            if (useHtmlDecode)
            {
                txt = System.Net.WebUtility.HtmlDecode(txt);
            }

            string attribute = string.Empty;

            if (this.Attribute == null && attributeTree != null)
            {
                if (this.Parent != null)
                {
                    attribute = RawlerBase.GetText(this.Parent.Text, attributeTree, this);
                }
            }
            else if (this.Attribute != null)
            {
                attribute = this.Attribute.Convert(this);
            }

            Data.DataWrite(this, attribute, txt, writeType, AttributeType);

            //IData data = null;

            //IRawler current = this.Parent;
            //while (current != null)
            //{
            //    if (current is IData)
            //    {
            //        data = current as IData;
            //        break;
            //    }
            //    current = current.Parent;
            //}
            //if (data != null)
            //{
            //    string txt = string.Empty;
            //    if (Value == null || Value.Length == 0)
            //    {
            //        txt = GetText();
            //    }
            //    else
            //    {
            //        txt = Value;
            //    }
            //    if (useHtmlDecode)
            //    {
            //        txt = System.Net.WebUtility.HtmlDecode(txt);
            //    }

            //    if (this.Attribute == null && attributeTree != null)
            //    {
            //        string tmpAttributeText = string.Empty;
            //        if (this.Parent != null)
            //        {
            //            tmpAttributeText = RawlerBase.GetText(this.Parent.Text, attributeTree,this);

            //        }
            //        data.DataWrite(tmpAttributeText, txt, writeType,AttributeType);

            //    }
            //    else
            //    {
            //        if (this.Attribute != null)
            //        {
            //            data.DataWrite(this.Attribute, txt, writeType,AttributeType);
            //        }
            //        else
            //        {
            //            data.DataWrite(string.Empty, txt, writeType, AttributeType);
            //        }
            //    }

            //    //if (this.AttributeObjectName != null && this.AttributeObjectName.Length>0)
            //    //{
            //    //    var list = this.GetConectAllRawler().Where(n => n.Name == this.AttributeObjectName);
            //    //    if (list.Count() > 0)
            //    //    {
            //    //        data.DataWrite(list.First().Text, txt,writeType);
            //    //    }
            //    //    else
            //    //    {
            //    //        ReportManage.ErrReport(this, "AttributeObjectNameの指定が不正です。オブジェクトが見つかりませんでした。");
            //    //    }
            //    //}

            //}
            //else
            //{
            //    ReportManage.ErrReport(this,"書き込み先のDataオブジェクトが見つかりません。");
            //}
            this.RunChildren(runChildren);
        }