Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
        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;
        }
Ejemplo n.º 3
0
        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;
        }
Ejemplo n.º 4
0
        public static string FindTXTContent(TAGBlock block)
        {
            if (block == null || block.Name == null)
            {
                return(string.Empty);
            }
            string ret = string.Empty;

            if (Included.Contains(block.Name) && !Excluded.Contains(block.Name))
            {
                ret += (SplitHtml.GetAllInsideContent(block));
            }
            else if (block.FirstInside != null && !Excluded.Contains(block.Name))
            {
                ret += FindTXTContent(block.FirstInside);
            }
            if (block.NextBlock != null)
            {
                ret += FindTXTContent(block.NextBlock);
            }
            return(ret);
        }