//Wrapper that can be used to run the program continuously, as a test. Not fully fleshed out, but it exists to //test consistency private static void Main() { var runsPassed = 0; var totalScraperRunTime = 0.000; const int testPasses = 5; for (var i = 0; i < testPasses; i++) { using (var outputCapture = new OutputCapture()) { var watch = System.Diagnostics.Stopwatch.StartNew(); try { InitializeScraper.SetUp(new ScraperOptions("", string.Empty, string.Empty, true, false, false, false, string.Empty)); } catch (NullReferenceException) { Logger.Error("Null reference, counting as failure."); continue; } watch.Stop(); totalScraperRunTime += watch.ElapsedMilliseconds; System.Threading.Thread.Sleep(2000); var logMessages = outputCapture.Captured.ToString(); if (logMessages.Contains("Processed 93 files.")) { runsPassed++; } } } Console.WriteLine("{0}% of runs returned all links", runsPassed * (100 / testPasses)); Console.WriteLine("It took the scraper {0} seconds on average, per test", totalScraperRunTime / (testPasses * 1000.00)); }
private void OnClickedEvent(object sender, EventArgs args) { if (!(sender is Button clickedButton)) { return; } if (clickedButton.Name.Equals("RunScraperButton")) { //Error Validation var errorMessages = new StringBuilder(); if (!_onlyGetStoryBox.ChildVisible) { _onlyGetStoryBox.Active = false; } if (_targetAccount.Text.Equals(string.Empty)) { errorMessages.Append("You must provide a target account\n"); } if (!_username.Text.Equals(string.Empty) && _password.Text.Equals(string.Empty) || _username.Text.Equals(string.Empty) && !_password.Text.Equals(string.Empty)) { errorMessages.Append("Please fill out both the username and password fields, or leave them blank\n"); } if (_getStoryBox.Active && (_username.Text.Equals(string.Empty) || _password.Text.Equals(string.Empty))) { errorMessages.Append("In order to view stories, Instagram requires login details\n"); } if (_onlyGetStoryBox.Active && !_getStoryBox.Active) { errorMessages.Append("Please select the \"Download the Target Account's Story\" to continue with the capture of only the user's story\n"); } if (_onlyGetStoryBox.Active && _getCommentsBox.Active) { errorMessages.Append("The \"Only Get Story\" option is not allowed to be used in conjunction with retrieving comments\n"); } if (!errorMessages.ToString().Equals(string.Empty)) { var errorMessageDialog = new MessageDialog(this, DialogFlags.DestroyWithParent, MessageType.Error, ButtonsType.Close, errorMessages.ToString()); errorMessageDialog.Run(); errorMessageDialog.Destroy(); } else { try { InitializeScraper.SetUp(new ScraperOptions(_targetAccount.Text, _username.Text, _password.Text, _headlessBrowserBox.Active, _getStoryBox.Active, _getCommentsBox.Active, _onlyGetStoryBox.Active, _savePath.Text)); } catch (Exception e) { Logger.Debug("Exception " + e + " was thrown."); } } } else if (clickedButton.Name.Equals("ChooseSavePathButton")) { var fileChooserDialog = new FileChooserDialog("Choose a file", this, FileChooserAction.SelectFolder, "Cancel", ResponseType.Cancel, "Select", ResponseType.Accept); if (fileChooserDialog.Run() == (int)ResponseType.Accept) { _savePath.Text = fileChooserDialog.Filename; } fileChooserDialog.Destroy(); } else if (clickedButton.Name.Equals("StoryCheckBox")) { _onlyGetStoryBox.ChildVisible = !_onlyGetStoryBox.ChildVisible; } }