Пример #1
0
 private void Analysis()
 {
     _state = true;
     SetControlEnable(ButtonAnalysis, false);
     if (!String.IsNullOrEmpty(textBoxUrl.Text.TrimStart().TrimEnd()))
     {
         IAnalysis analysis = ArticleAnalysisFactory.Instance().CreateAnalysis(1);
         if (analysis != null)
         {
             ArticleDownAction downAction  = new ArticleDownAction();
             String            html        = downAction.GetHtml(textBoxUrl.Text.TrimStart().TrimEnd());
             ArticleModel      article     = analysis.Analysis(html);
             String            articleJson = Newtonsoft.Json.JsonConvert.SerializeObject(article);
             AddMessage(articleJson);
         }
         else
         {
             AddMessage("暂时还未支持该站点的文章采集,程序猿正在紧张处理中!!!");
         }
     }
     else
     {
         AddMessage("请输入需要采集的文章地址!");
     }
     _state = false;
     SetControlEnable(ButtonAnalysis, true);
 }
Пример #2
0
 private void SimpleAnalysis()
 {
     _state = true;
     SetControlEnable(buttonSimpleAnalysis, false);
     if (!String.IsNullOrEmpty(textBoxUrl.Text.TrimStart().TrimEnd()))
     {
         IAnalysis analysis = ArticleAnalysisFactory.Instance().CreateAnalysis(1);
         if (analysis != null)
         {
             ArticleDownAction downAction = new ArticleDownAction();
             String            html       = downAction.GetHtml(textBoxUrl.Text.TrimStart().TrimEnd());
             _simpleArticleModel = analysis.SimpleAnalysis(html);
             String        articleJson = Newtonsoft.Json.JsonConvert.SerializeObject(_simpleArticleModel);
             StringBuilder builder     = new StringBuilder();
             builder.AppendFormat("<html><body>{0}</body></html>", _simpleArticleModel.ContentModels);
             _filePath = String.Format(@"{0}html\\htmltest_{1}.html", AppDomain.CurrentDomain.BaseDirectory, DateTime.Now.ToString("ffff"));
             File.WriteAllText(_filePath, builder.ToString(), Encoding.Unicode);
             //_filePath = string.Format("file:///{0}", _filePath);
             AddMessage(articleJson);
         }
         else
         {
             AddMessage("暂时还未支持该站点的文章采集,程序猿正在紧张处理中!!!");
         }
     }
     else
     {
         AddMessage("请输入需要采集的文章地址!");
     }
     _state = false;
     SetControlEnable(buttonSimpleAnalysis, true);
 }