Example #1
0
        // @Throws
        public static FindResult Find(string PageUrl)
        {
            using (var client = WebClientNoCache())
            {
                var mainPageSource = client.DownloadString(PageUrl);
                var urls           = GetUrls(mainPageSource);

                foreach (var i in urls)
                {
                    try
                    {
                        var src = client.DownloadString(i);

                        if (src.Length >= sourceCodeLenCriteria * 10)
                        {
                            return(new FindResult()
                            {
                                Url = i, Source = src
                            });
                        }
                        if (src.Length >= sourceCodeLenCriteria)
                        {
                            return(LastestDataSetFinder.Find(i));
                        }
                    }
                    catch { }
                }

                throw new WindNotAvailException();
            }
        }
Example #2
0
        // Can throw exception.
        public void DownloadGribFile(string filePath)
        {
            var x = LastestDataSetFinder.Find();

            webPageUrl = x.Url;
            webPageSrc = x.Source;

            try
            {
                using (var client = new WebClient())
                {
                    var dir = new FileInfo(filePath).DirectoryName;
                    Directory.CreateDirectory(dir);
                    client.DownloadFile(FileUrl(), filePath);
                }
            }
            catch (Exception ex)
            {
                throw new DownloadGribFileException("", ex);
            }
        }