Beispiel #1
0
        public CopyPageResult CopyPage(string webPage)
        {
            CopyPageResult result = new CopyPageResult();

            try
            {
                HtmlDocument page = web.Load(webPage);
                result.Page = new SiteFile(webPage, DownloadPage("C:\\Temp", webPage));

                if (webPage.ToLowerInvariant().Contains(".css"))
                {
                    result.Links.AddRange(GetLinksFromCSS(Website.AbsoluteUri, webPage).ToArray());
                }
                else
                {
                    result.Links.AddRange(GetLinks(Website.AbsoluteUri, page).ToArray());
                }
            }
            catch (Exception ex)
            {
                LastException = ex;
            }

            return(result);
        }
Beispiel #2
0
        private void CopySite(string startPage)
        {
            downloadQ.Enqueue(startPage);
            List <string> downloadedPages = new List <string>();

            do
            {
                CopyPageResult result = copyManager.CopyPage(downloadQ.Dequeue());
                bgProcess.ReportProgress(0, result.Page);

                if (result.Page.Downloaded)
                {
                    downloadedPages.Add(result.Page.Filename);
                }

                foreach (string page in result.Links.Distinct().ToArray())
                {
                    if ((!downloadedPages.Contains(page)) & (!downloadQ.Contains(page)))
                    {
                        downloadQ.Enqueue(page);
                    }
                }

                //downloadQ.Clear ();
                //downloadQ = new Queue<string>(downloadQ.Distinct());
            } while (downloadQ.Count > 0);
        }