protected bool ReadPage(string url) { var client = GetWebClient(); parameterList.Clear(); httpHeaderList.Clear(); BeforeTrees.Run(this, GetText()); if (InputParameterTree != null) { RawlerBase.GetText(GetText(), InputParameterTree, this); } if (MethodType == Tool.MethodType.GET) { this.text = client.HttpGet(url, parameterList, httpHeaderList); } else if (MethodType == Tool.MethodType.POST) { this.text = client.HttpPost(url, parameterList, httpHeaderList); } this.currentUrl = url; this.pastUrl = this.currentUrl; if (this.Text.Length > 0) { return(true); } else { if (client.ErrMessage != null && (client.ErrMessage.Contains("503") || client.ErrMessage.Contains("500"))) { ReportManage.ErrReport(this, $"{client.ErrMessage} {url}の読み込みに失敗しました。"); } else { if (visbleErr) { ReportManage.ErrReport(this, url + "の読み込みに失敗しました。"); } if (ErrorEvent != null) { ErrorEvent(this, new EventArgs()); } if (ErrEventTree != null) { ErrEventTree.SetParent(); Document d = new Document() { TextValue = client.ErrMessage }; d.SetParent(this); d.AddChildren(ErrEventTree); d.Run(); } } return(false); } }
public void addDocument(string text, RawlerBase rawlerTree) { var d = new Document(); d.SetText(text); d.SetParent(this); var tree = rawlerTree.Clone(); d.AddChildren(tree); documents.Add(d); }
public void addDocument(string text, ICollection<RawlerBase> rawlerTrees) { var d = new Document(); d.SetText(text); d.SetParent(this); foreach (var item in rawlerTrees) { var tree = item.Clone(); d.AddChildren(tree); } documents.Add(d); }
public void addDocument(string text, ICollection <RawlerBase> rawlerTrees) { var d = new Document(); d.SetText(text); d.SetParent(this); foreach (var item in rawlerTrees) { var tree = item.Clone(); d.AddChildren(tree); } documents.Add(d); }
public static string GetText(string text, RawlerBase rawler, RawlerBase parent) { Document doc = new Document(); doc.SetText(text); if (parent != null) { doc.SetParent(parent); } rawler.SetParent(doc); rawler.SetParent(); var last = rawler.GetDescendantRawler().Last(); rawler.Run(); return(last.Text); }
/// <summary> /// このクラスでの実行すること。 /// </summary> /// <param name="runChildren"></param> public override void Run(bool runChildren) { var login = this.GetAncestorRawler().OfType<TwitterLogin>().First(); bool flag = true; Dictionary<string, object> dic = new Dictionary<string, object>(); string track; if(TrackTree !=null) { TrackTree.SetParent(this); track = RawlerBase.GetText(GetText(), TrackTree,this); } else { track = Track; } dic.Add("track",track); var stream = login.Token.Streaming.StartObservableStream(StreamingType.Filter,new StreamingParameters(dic)).Publish(); stream.OfType<StatusMessage>() .Subscribe(x => { Document d = new Document() { TextValue = Codeplex.Data.DynamicJson.Serialize(x.Status) }; d.SetParent(this); foreach (var item in this.Children) { d.AddChildren(item); } d.Run(); }); stream.OfType<WarningMessage>().Subscribe(x => ReportManage.ErrReport(this, x.Message)); //// stream.OfType<EventMessage>() // .Subscribe(x => Console.WriteLine("{0} by @{1}", x.Event, x.Source.ScreenName)); disposable = stream.Connect(); }