public ContentHandle(string link) { this.LINK = link; this.WEBPAGE = WebHandle.GetHTMLPage(link, null); if (this.WEBPAGE != null) { this.contentTree = SplitHtml.SplitTo(this.WEBPAGE); } this.RootUrl = WebHandle.getRootUrl(this.LINK); }
private void GetTXT_Click(object sender, RoutedEventArgs e) { this.Cursor = Cursors.Wait; TEXTBOX_View.Clear(); var matchLinks = Regex.Matches(this.TEXTBOX_Links.Text, @"\s*.+(\s+|$)"); foreach (Match link in matchLinks) { if (link.Success) { var content = new ContentHandle(link.Value.Trim()); if (WebHandle.getRootUrl(link.Value.Trim()) == null) { if (MessageBox.Show(link.Value.Trim() + "链接格式错误", "是否继续", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { continue; } else { return; } } if (content.WEBPAGE == null) { if (MessageBox.Show(link.Value.Trim() + "无法获取内容", "是否继续", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { continue; } else { return; } } SplitHtml.RefreshUserSettings(); string append = SplitHtml.FindTXTContent(content.contentTree); this.Dispatcher.BeginInvoke(new Action <string>(delegate(string Toappend) { TEXTBOX_View.AppendText(Toappend); }), append); //TEXTBOX_View.AppendText(SplitHtml.FindTXTContent(content.contentTree)); } } this.Cursor = Cursors.Arrow; }
private void GetIndexesLink_Click(object sender, RoutedEventArgs e) { this.Cursor = Cursors.Wait; var matchLinks = Regex.Matches(this.TEXTBOX_Links.Text, @"\s*.+(\s+|$)"); foreach (Match link in matchLinks) { if (link.Success) { var content = new ContentHandle(link.Value.Trim()); if (WebHandle.getRootUrl(link.Value.Trim()) == null) { if (MessageBox.Show(link.Value.Trim() + "链接格式错误", "是否继续", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { continue; } else { return; } } if (content.WEBPAGE == null) { if (MessageBox.Show(link.Value.Trim() + "无法获取内容", "是否继续", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { continue; } else { return; } } var links = SplitHtml.GetLinks(content.contentTree); //TEXTBOX_Links.Clear(); foreach (var l in links) { TEXTBOX_View.AppendText ((string.IsNullOrEmpty(WebHandle.getRootUrl(l.Key)) ? content.RootUrl + l.Key : l.Key) + "\n"); } } } this.Cursor = Cursors.Arrow; }