public ActionResult Index(Website website)
        {
            if (website == null || string.IsNullOrEmpty(website.URL))
            {
                return(new HttpStatusCodeResult(HttpStatusCode.Unauthorized));
            }

            try
            {
                var wcService = new WebParserService();

                var           wcList    = wcService.Parse(website.URL);
                List <string> wordList  = wcList.Select(m => m.WordText).ToList();
                List <int>    countList = wcList.Select(m => m.Count).ToList();

                var   wc      = new WordCloud(800, 800);
                Image wcImage = wc.Draw(wordList, countList);

                byte[] imageByteData   = imageToByteArray(wcImage);
                string imageBase64Data = Convert.ToBase64String(imageByteData);
                string imageDataURL    = string.Format("data:image/png;base64,{0}", imageBase64Data);
                ViewBag.ImageData = imageDataURL;

                return(View());
            }
            catch (Exception)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError));
            }
        }
Beispiel #2
0
        private static async Task Main(string[] args)
        {
            using (IParserService parser = new WebParserService())
            {
                try
                {
                    var htmlDOM = await parser.ParseAsync(SampleUrl);

                    await parser.LoadIconAsync(htmlDOM);
                }
                catch (Exception ex)
                {
                    WriteError(ex.Message);
                }
            }

            Console.WriteLine("Done");
            Console.ReadKey();
        }