public WebClient GetWebClient() { WebClient client = this.GetUpperRawler <WebClient>(); if (client == null) { ReportManage.ErrUpperNotFound <WebClient>(this); ReportManage.ErrReport(this, "新しいWebClientを作成します"); client = new WebClient(); } if (useReferer) { if (pastUrl == string.Empty) { var pages = this.GetUpperRawler <Page>(); tmpReferer = pages?.GetCurrentUrl(); } else { tmpReferer = pastUrl; } } else { tmpReferer = string.Empty; } var enc = GetEncoding(); if (enc != null) { client.Encoding = encoding; } return(client); }
public override void Run(bool runChildren) { var g = this.GetUpperRawler <GroupBy>(); if (g == null) { ReportManage.ErrUpperNotFound <GroupBy>(this); return; } RunChildrenForArray(runChildren, g.GetCurrentKeyValue().Value); }
public override void Run(bool runChildren) { var g = this.GetUpperRawler <GroupBy>(); if (g == null) { ReportManage.ErrUpperNotFound <GroupBy>(this); return; } SetText(g.GetCurrentKeyValue().Key); base.Run(runChildren); }
public override void Run(bool runChildren) { var d = this.GetUpperRawler <Data>(); if (d == null) { ReportManage.ErrUpperNotFound <Data>(this); } else { } base.Run(runChildren); }
/// <summary> /// AddDataRowの共通呼び出し。 /// </summary> /// <param name="rawler"></param> /// <param name="datarow"></param> public static void AddDataRow(RawlerBase rawler, DataRowObject datarow) { var r = (IDataRows)rawler.GetUpperInterface <IDataRows>(); if (r != null) { r.AddDataRow(datarow); } else { ReportManage.ErrUpperNotFound <IDataRows>(rawler); } }
/// <summary> /// DataWriteの共通呼び出し /// </summary> /// <param name="rawler"></param> /// <param name="attribute"></param> /// <param name="value"></param> /// <param name="type"></param> /// <param name="attributeType"></param> public static void DataWrite(RawlerBase rawler, string attribute, string value, DataWriteType type, DataAttributeType attributeType) { var d = (IData)rawler.GetUpperInterface <IData>(); if (d != null) { d.DataWrite(attribute, value, type, attributeType); } else { ReportManage.ErrUpperNotFound <IData>(rawler); } }
public override void Run(bool runChildren) { var loop = this.GetUpperRawler <Loop>(); if (loop != null) { loop.Break(); } else { ReportManage.ErrUpperNotFound <Loop>(this); } base.Run(runChildren); }
public override void Run(bool runChildren) { var file = this.GetAncestorRawler().Where(n => n is FileReadLines); if (file.Count() > 0) { SetText(file.First().Text); } else { ReportManage.ErrUpperNotFound <FileReadLines>(this); } base.Run(runChildren); }
/// <summary> /// 指定したキーが上流のKeyValueStoreにあるかを調べる /// </summary> /// <param name="rawler"></param> /// <param name="keys"></param> /// <returns></returns> public static bool ContainsKey(RawlerBase rawler, params string[] keys) { var r = rawler.GetUpperRawler <KeyValueStore>(); if (r != null) { return(keys.All((n) => r.dic.ContainsKey(n))); } else { ReportManage.ErrUpperNotFound <KeyValueStore>(rawler); } return(false); }
/// <summary> /// このクラスでの実行すること。 /// </summary> /// <param name="runChildren"></param> public override void Run(bool runChildren) { if (keyValueStore == null) { keyValueStore = this.GetUpperRawler <KeyValueStore>(); } if (keyValueStore != null) { if (string.IsNullOrEmpty(Value)) { keyValueStore.SetKeyValue(Key, GetText()); } else { keyValueStore.SetKeyValue(Key, Value); } } else { ReportManage.ErrUpperNotFound <KeyValueStore>(this); } SetText(GetText()); base.Run(runChildren); }
public override void Run(bool runChildren) { var pages = this.GetAncestorRawler().Where(n => n is Page); if (pages.Count() > 0) { var html = Html.Convert(this); if (string.IsNullOrEmpty(html)) { html = GetText(); } var targetName = TargetName.Convert(this); if (string.IsNullOrEmpty(targetName) == false) { if (pages.Where(n => n.Name == targetName).Any()) { pages.Where(n => n.Name == targetName).First().SetText(html); } else { ReportManage.ErrReport(this, "TargetName「" + targetName + "」が見つかりません"); } } else { pages.First().SetText(html); } SetText(html); } else { ReportManage.ErrUpperNotFound <Page>(this); } base.Run(runChildren); }