Example #1
0
        }//end changeProgress

        private void ScrapeZacks()
        {
            //Console.WriteLine("In Zacks try");
            ChangeProgress(0, "Loading Zacks...", chartMillRows.Count);
            for (int i = 0; i < symbols.Count && !frmSplash.GetCancelled(); i++)
            {
                try
                {
                    string url = String.Format("{0}{1}{2}{3}", zacksUrl[0], symbols[i], zacksUrl[1], symbols[i]);
                    ChangeProgress(1, String.Format("Scraping Zacks - {0}", symbols[i]));
                    driver.Url = url;
                    driver.Navigate();
                    try
                    {
                        /*var etf = driver.FindElements(By.ClassName("rankrect_NA"));
                         * if (etf != null)
                         * {
                         *  throw new NoSuchElementException();
                         * }*/
                        System.Collections.ObjectModel.ReadOnlyCollection <IWebElement> element = driver.FindElements(By.ClassName("rank_view"));
                        if (element == null || element.Count <= 0)
                        {
                            throw new NoSuchElementException();
                        }
                        zacksText.Add(element.ElementAt(0).Text.Split(new char[] { '-', '\r', '\n' }));
                    } catch (NoSuchElementException e)
                    {
                        zacksText.Add(new string[] { "", "" });
                    }
                } catch (TimeoutException)
                {
                    i--;
                    timeOuts++;
                    //Console.WriteLine("In Zacks catch.  timeOuts = " + timeOuts.ToString());
                    if (timeOuts > 4)
                    {
                        frmScreener.ErrorMessage(new Exception("Number of browser timeouts exceded.  Consider taking the following actions and try again.\n1. Clear the browsers cached images and files.\n2. Download an Ad Blocker extension.\n3. Close open browsers.\n4. Close additional running applications."));
                        Environment.Exit(1);
                    }
                } //end try-catch
            }     //end for
        }         //end ScrapeZacks