Beispiel #1
0
        /// <summary>
        /// Defines the entry point of the application.
        /// </summary>
        /// <param name="args">The arguments.</param>
        private static void Main(string[] args)
        {
            try
            {
                // make chrome run in headless mode
                ChromeOptions option = new ChromeOptions();
                option.AddArgument("--headless");
                IWebDriver    driver = new ChromeDriver(option);
                DataContainer data   = new DataContainer();

                string        URL             = "http://anandrathi.accordfintech.com/Equity/BulkDeals.aspx?id=22&Option=&EXCHG=";
                string        URLBSE          = URL + "BSE";
                string        URLNSE          = URL + "NSE";
                string        documentsFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                DirectoryInfo dir             = new DirectoryInfo(documentsFolder);
                //Taking arguments from command-line
                string strtDate, endDate, exchange; //start date is always lesser then end date as start date will be in the past

                if (args.Length == 3)
                {
                    strtDate = args[0];
                    endDate  = args[1]; //start date is always lesser then end date as start date will be in the past
                    exchange = args[2]; // BSE || NSE || Both
                }
                else
                {
                    //Fallback to generic arguments incase of missing commandline arguments
                    strtDate = DateTime.Today.AddDays(-2).ToString("dd-MM-yyyy");
                    endDate  = DateTime.Today.AddDays(-1).ToString("dd-MM-yyyy"); //start date is always lesser then end date as start date will be in the past
                    exchange = "both";
                }

                Console.Clear();
                Console.WriteLine("********************************Getting data from ANAND RATHI Web Table**********************************************");
                Console.WriteLine();

                if (args.Length == 0)
                {
                    System.Threading.Thread.Sleep(500);
                    Console.WriteLine("No Arguments Provided!!");
                    System.Threading.Thread.Sleep(500);
                    Console.WriteLine("Options: BulkDealsSensex.exe START-DATE END-DATE bse or nse or both");
                    System.Threading.Thread.Sleep(500);
                    Console.WriteLine("Command: BulkDealsSensex.exe dd-MM-yyyy dd-MM-yyyy both ");
                    System.Threading.Thread.Sleep(500);
                    Console.WriteLine("Falling back.......");
                    System.Threading.Thread.Sleep(500);
                }

                if (exchange.ToLower() == "bse")
                {
                    FinalMethodToGetData(driver, URLBSE, dir, strtDate, endDate, exchange);
                }
                else if (exchange.ToLower() == "nse")
                {
                    FinalMethodToGetData(driver, URLNSE, dir, strtDate, endDate, exchange);
                }
                else if (exchange.ToLower() == "both")
                {
                    FinalMethodToGetDataForBoth(driver, URL, dir, strtDate, endDate);
                }
                driver.Quit();
            }
#pragma warning disable CA1031 // Do not catch general exception types
            catch (Exception e)
#pragma warning restore CA1031 // Do not catch general exception types
            {
                Console.WriteLine("!!!ERROR ENCOUNTERED!!!:::");
                Console.WriteLine(e.Message);
                Console.WriteLine("----------------------------");
                Console.WriteLine(e.InnerException);
                Console.WriteLine(e.StackTrace);
            }
            finally
            {
                Console.WriteLine();
                Console.WriteLine("******************************************Press any key to exit.........********************************************");
                Console.Read();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Finals the method to get data.
        /// </summary>
        /// <param name="driver">Selenium WebDriver Object.</param>
        /// <param name="URL">The URL.</param>
        /// <param name="dir">The dir.</param>
        /// <param name="strtDate">The STRT date.</param>
        /// <param name="endDate">The end date.</param>
        /// <param name="exchange">The exchange.</param>
        private static void FinalMethodToGetData(IWebDriver driver, string URL, DirectoryInfo dir, string strtDate, string endDate, string exchange)
        {
            DataContainer dc = CreateDataForExcel(driver, URL, strtDate, endDate, exchange);

            OutputDataToExcel(dc, dir, exchange);
        }