Пример #1
0
        public void GetWebContent(string url, int urlcnt, List <string> lstUrls)
        {
            string StringFromTheInput = url;
            string content            = String.Empty;

            using (var client = new WebClient())
            {
                //Get the content from Web URL
                content = client.DownloadString(StringFromTheInput);
            }

            //Get the List of URLS from Web Page
            lstUrls = new GetUrls().GetAllUrls(content, txtUrl.Text);
            foreach (var item in lstUrls)
            {
                using (var client = new WebClient())
                {
                    //Get the content from Web URL
                    content = client.DownloadString(StringFromTheInput);
                }
                //Add Top 10 Words from Each URL
                WCntSingle.AddRange(WordCount(content, 10));
                if (urlcnt >= 4)
                {
                    break;
                }
                urlcnt++;
                //Call Recursive Function For Going upto 4 level
                GetWebContent(item, urlcnt, lstUrls);
            }
        }
Пример #2
0
        public void GetWebContentPair(string url, int urlcnt, List <string> lstUrls)
        {
            string StringFromTheInput = url;
            string content            = String.Empty;

            using (var client = new WebClient())
            {
                //Get the content from Web URL
                content = client.DownloadString(StringFromTheInput);
            }

            //Get the List of URLS from Web Page
            lstUrls = new GetUrls().GetAllUrls(content, txtUrl.Text);
            var delimiterChars = new char[] { ' ' };

            foreach (var item in lstUrls)
            {
                try
                {
                    using (var client = new WebClient())
                    {
                        //Get the content from Web URL
                        content = client.DownloadString(StringFromTheInput);
                    }

                    //Logic To Find Out Pairs of Words
                    var contentpair = content.Split(delimiterChars);
                    var pairs       = new List <string>();
                    for (int i = 0; i < contentpair.Length - 1; i++)
                    {
                        if (contentpair[i].Trim() != "" && contentpair[i + 1].Trim() != "")
                        {
                            pairs.Add(contentpair[i] + " " + contentpair[i + 1]);
                        }
                    }
                    //Add Top 10 Pair Words from Each URL
                    WCntPair.AddRange(WordCountPair(pairs, 10));
                    if (urlcnt >= 4)
                    {
                        break;
                    }
                    urlcnt++;
                    //Call Recursive Function For Going upto 4 level
                    GetWebContentPair(item, urlcnt, lstUrls);
                }
                catch (Exception ex)
                {
                    //Exception Handling Here
                }
            }
        }