Example #1
0
        public static IProcessor CreateandReturnObj(string processorName)
        {
            IProcessor processor = null;

            if (processorName.ToLower() == "yahoo")
            {
                processor = new YahooProcessor();
            }
            //create other source API processors here
            return(processor);
        }
        public void StartCrawl()
        {
            //System.Windows.MessageBox.Show(Directory.GetCurrentDirectory());
            ChromeOptions options = new ChromeOptions();

            options.AddArgument("--disable-infobars");
            IWebDriver driver = new ChromeDriver(options);

            driver.Manage().Window.Maximize();
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(5.00));

            switch (SelectedWebsite.Type)
            {
            case WebsiteType.Yahoo:
                Processor    = new YahooProcessor();
                SaveFilePath = Config.YahooFileSavePath;
                break;

            case WebsiteType.Shopee:
                Processor    = new ShopeeProcessor();
                SaveFilePath = Config.ShopeeFileSavePath;
                break;

            default:
                break;
            }

            // 清空資料
            Config.ExcelData = new List <ExcelData>();

            foreach (string keyword in Keywords)
            {
                Processor.SearchKeyword(keyword, SelectedWebsite.CompareAccount, driver, wait);
            }

            // 寫入 Excel
            WriteExcelFile();

            driver.Quit();
        }