示例#1
0
文件: MainForm.cs 项目: AndrewHK/IDP
        private async void CrawlBtn_Click(object sender, EventArgs e)
        {
            const string clublistXml = "clubList.xml";

            const string backupRumorsFile        = "rumorlist.xlsx";
            const string backupRumorsSourcesFile = "rumorlistsources.xlsx";

            var url = new Uri(rumorMillTB.Text);

            /*
             * Utils.RetrieveClubs(filename);
             */
            var limitedList = new List <string> {
                "972770"
            };

            //http://www.transfermarkt.de/geruchtekuche/detail/forum/154/
            //http://www.transfermarkt.de/rumour-mill/detail/forum/500/

            const int jumpCount = 50;

            _tmParser.DetermineForumPageCount(url);
            for (var i = 51; i < 401; i += jumpCount)
            {
                string outFilename = string.Format("RumorMill_German({0}-{1}).xlsx", i, i + jumpCount - 1);

                try
                {
                    _tmParser.ParseForum(i, i + jumpCount - 1);
                    await _tmParser.NavigateToRumorPages();

                    //MessageBox.Show("Navigation done!");
                    //navGB.BackColor = System.Drawing.Color.MediumSeaGreen;

                    //Utils.SerializeObject(_tmParser.GetRumorsList(), backupRumorsFile);
                    //Utils.SerializeObject(_tmParser.GetRumorsSourcesList(), backupRumorsSourcesFile);

                    _tmParser.UpdateRumorsSources();
                    //MessageBox.Show("Rumor Sources updated!");
                    //rumorSrcGB.BackColor = System.Drawing.Color.MediumSeaGreen;


                    _tmParser.UpdateInterestedClubs(clublistXml);
                    //MessageBox.Show("Interested Clubs retrieved!");
                    //interClubGB.BackColor = System.Drawing.Color.MediumSeaGreen;

                    _tmParser.DetermineRumorType();
                    //MessageBox.Show("Rumor Types determined!");
                    //rumorTypeGB.BackColor = System.Drawing.Color.MediumSeaGreen;

                    CreateExcelFile.CreateRumorsCompleteExcelDocument(_tmParser.GetRumorsList(),
                                                                      _tmParser.GetRumorsSourcesList(), outFilename);
                    //MessageBox.Show("Excel sheet created!");
                    //excelSheetGB.BackColor = System.Drawing.Color.MediumSeaGreen;
                }
                catch
                {
                }
                _tmParser.Refresh();
            }
        }