Пример #1
0
        static void Main(string[] args)
        {
            string[] lines = File.ReadAllLines(TEAM_CODE_FILE);

            foreach (string line in lines)
            {
                string[] parts = line.Split('\t');
                string   code  = parts[0];
                string   name  = parts[1];
                TeamMapping[name] = code;
                TeamMapping[code] = name;
            }

            string mode = args[0];

            // set paths
            if (args.Length > 3)
            {
                CACHE_PATH  = args[3];
                OUTPUT_PATH = args[4];
            }

            if (mode == "crawl")
            {
                int startYear = int.Parse(args[1]);
                int endYear   = int.Parse(args[2]);// set paths

                ErrorLog = new StreamWriter(Path.Combine(OUTPUT_PATH, "Error.log"));

                /*
                 * for (int year = endYear; year >= startYear; year--)
                 * {
                 *  foreach (string team in teams)
                 *  {
                 *      CrawlTeam(team, year);
                 *  }
                 * }
                 */

                // seed the crawl with the first month of the seasons
                Dictionary <string, bool> dates   = new Dictionary <string, bool>();
                HashSet <string>          visited = new HashSet <string>();
                string[] months = new string[] { "11", "12", "01", "02", "03", "04" };

                for (int year = endYear; year >= startYear; year--)
                {
                    foreach (string month in months)
                    {
                        string yearStr = (month.StartsWith("0") ? (year + 1).ToString() : year.ToString());
                        string start   = yearStr + "-" + month + "-01";

                        CrawlDate(start, visited);
                    }
                }

                // close open streams if we have them
                if (GameStream != null)
                {
                    GameStream.Close();
                }
                if (PlayerStream != null)
                {
                    PlayerStream.Close();
                }
                ErrorLog.Close();
            }

            if (mode == "game")
            {
                CrawlGame(args[1]);
            }
        }