Exemple #1
0
        ///gets all stock information from a year ago to today
        private static TimeInterval[] GetTimeIntervals(string _stockName)
        {
            bool _unavailable = false;                                      //bool to work out when to stop scraping information
            int  _n           = 0;                                          // integar to count page numbers
            List <TimeInterval> _timeIntervals = new List <TimeInterval>(); //list to store everyday of stock information specified
            string _startDate = DateHandling.GetCurrentYahooDate(0);
            string _endDate   = DateHandling.GetStartDate();

            //this loop will only run while there is information to scrape
            while (!_unavailable)
            {
                string         _address = GetAddress(_stockName, _startDate, _endDate, _n);         // address for next webpage
                TimeInterval[] _currentTimeIntervals = GetInformationOfPage(_address);              // getting stock info of webpage
                if (_currentTimeIntervals == null)
                {
                    _unavailable = true;
                }
                else
                {
                    _timeIntervals.AddRange(_currentTimeIntervals);
                }
                _n++;
            }
            _timeIntervals.Reverse();

            return(_timeIntervals.ToArray());
        }