Esempio n. 1
0
        public TVMazeHttpClient(HttpClient client, ILogger <TVMazeHttpClient> logger, IOptions <ScraperSettings> options)
        {
            settings = options?.Value ?? throw new ArgumentNullException(nameof(options));

            this.client = client ?? throw new ArgumentNullException(nameof(client));
            this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
        }
Esempio n. 2
0
        private string ReplaceTokens(ScraperSettings _settings, string message, string fname, string lname, string job)
        {
            foreach (var st in _settings.SpecialToekns)
            {
                switch (st.ToLower())
                {
                case "{firstname}":
                {
                    message = message.Replace(st, fname);
                }
                break;

                case "{lastname}":
                {
                    message = message.Replace(st, lname);
                }
                break;

                case "{jobtitle}":
                {
                    message = message.Replace(st, job);
                }
                break;
                }
            }

            return(message);
        }
        public static bool SaveSettings(ScraperSettings settings)
        {
            string data = JsonConvert.SerializeObject(settings);

            File.WriteAllText(Util.ScraperSettingsFileName, data);
            return(true);
        }
Esempio n. 4
0
 public Scraper(HttpClient client, IOptions <ScraperSettings> options,
                ILogger <Scraper> logger)
 {
     _client   = client;
     _settings = options?.Value;
     _logger   = logger;
 }
Esempio n. 5
0
 public ScraperService(ILogger <ScraperService> logger, ITVShowsRepository tvShowRepository, ITVMazeHttpClient tvMazeHttpClient, IOptions <ScraperSettings> options)
 {
     this.logger           = logger ?? throw new ArgumentNullException(nameof(logger));
     this.tvShowRepository = tvShowRepository ?? throw new ArgumentNullException(nameof(tvShowRepository));
     this.tvMazeHttpClient = tvMazeHttpClient ?? throw new ArgumentNullException(nameof(tvMazeHttpClient));
     settings = options?.Value ?? throw new ArgumentNullException(nameof(options));
 }
Esempio n. 6
0
        public (string, string) GetGreetingAndMessage(LIUserData up, ScraperSettings _settings, string greeting, string message)
        {
            var tp = SplitUserName2(up.ProfileTitle);

            if (!string.IsNullOrWhiteSpace(greeting))
            {
                greeting = ReplaceTokens(_settings, greeting, tp.Item1, tp.Item2, up.CurrentJobTitle);
            }
            if (!string.IsNullOrWhiteSpace(message))
            {
                message = ReplaceTokens(_settings, message, tp.Item1, tp.Item2, up.CurrentJobTitle);
            }

            return(greeting, message);
        }
        public LIScraper(ScraperSettings sett)
        {
            _settings = sett;
            r         = new Random();
            _util     = new ScraperUtil(sett.UseOffScreenScraper);

            Logger.Debug("Initializing Web browser driver...");

            _driver = new ChromeDriver(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), _util.GetChromeProfile());

            Logger.Debug("Setting web driver configurations...");

            _driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(_settings.ImplicitTimeout);
            _wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(_settings.ScraperTimeout));
        }
        public static ScraperSettings GetSettings()
        {
            ScraperSettings settings = null;

            try
            {
                string data = File.ReadAllText(Util.ScraperSettingsFileName);
                settings = JsonConvert.DeserializeObject <ScraperSettings>(data);
            }
            catch (Exception ex)
            {
                settings = new ScraperSettings();
            }

            return(settings);
        }
Esempio n. 9
0
 public InstagramEventHandler(
     IWebDriver webDriver,
     ScraperAccountDao accountRepository,
     InstagramProfileDao profileDao,
     ScraperSettings scraperSettings,
     IScraperValidator scraperValidator,
     ILogger logger,
     NotificationSender notificationSender)
 {
     _webDriver          = webDriver;
     _accountDao         = accountRepository;
     _profileDao         = profileDao;
     _scraperSettings    = scraperSettings;
     _scraperValidator   = scraperValidator;
     _logger             = logger;
     _notificationSender = notificationSender;
 }
Esempio n. 10
0
        private void btnConnectRequest_Click(object sender, EventArgs e)
        {
            try
            {
                if (liUserProfiles == null || liUserProfiles.Count <= 0)
                {
                    MessageBox.Show("No User Profiles found  for this action", "No Profiles", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                var selectedUserProfiles = liUserProfiles.Where(s => s.IsSelected).ToList();

                if (selectedUserProfiles == null || selectedUserProfiles.Count <= 0)
                {
                    MessageBox.Show("No Profiles Selected for this action", "No Profiles", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                busyTab = 1;

                ShowBusyForm_Tab1(true);

                var data = Mapper.Map <List <LIUserData>, List <LIUserConnectRequestReport> >(selectedUserProfiles);

                settings = SraperSettingsManager.GetSettings();
                var scraper = new LIScraper(settings);


                var done = scraper.StartConnectRequestFlow(data);

                ShowBusyForm_Tab1(false);
                scraper.ShutdownScraper();

                UpdateStatus("Generating Report File");
                string f = CSVFileManager.WriteConnectionRequestReport(settings.ConnReportPath, data);

                MessageBox.Show($"Successfully Sent Connection Requests to selected UserProfiles. A report has also been generated {f} ", "Connection Request", MessageBoxButtons.OK, MessageBoxIcon.Information);
                busyTab = 0;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error Creating Direct Message Schedule Data File", MessageBoxButtons.OK, MessageBoxIcon.Error);
                busyTab = 0;
                ShowBusyForm_Tab1(false);
            }
        }
Esempio n. 11
0
        private void CloseScraper()
        {
            try
            {
                if (connScraper != null)
                {
                    connScraper.ShutdownScraper();
                }

                connScraper    = null;
                settings       = null;
                searchCriteria = null;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Scraper Shutdown Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 12
0
        private async void btnSearchLinkedIn_Click(object sender, EventArgs e)
        {
            try
            {
                busyTab = 1;

                settings = SraperSettingsManager.GetSettings();

                if (string.IsNullOrWhiteSpace(settings.LIUserName) || string.IsNullOrWhiteSpace(settings.LIPassword))
                {
                    throw new Exception("LinkedIn UserName or Password cannot be blank");
                }

                searchCriteria         = new SearchCriteria();
                searchCriteria.Keyword = this.txtKeyword.Text;
                searchCriteria.City    = this.txtCity.Text;
                searchCriteria.State   = this.cmbState.Text;
                searchCriteria.Company = this.txtCompany.Text;

                this.dgvLinkedInResult.Rows.Clear();
                this.rtbConnectLog.Clear();

                liUserProfiles = new List <LIUserData>();
                dgvLinkedInScrapingResultSource            = new BindingSource();
                dgvLinkedInScrapingResultSource.DataSource = liUserProfiles;
                dgvLinkedInResult.DataSource = dgvLinkedInScrapingResultSource;

                this.grpConnectNow.Enabled      = false;
                this.grpConnectSchedule.Enabled = false;

                connScraper = new LIScraper(settings);
                pageNo      = 1;

                ScrapeLinkedIn(connScraper, searchCriteria, pageNo);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Scraping Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                busyTab = 0;
            }
        }
 public InstagramProfile(InstagramProfileDao profileDao, ScraperSettings scraperSettings, IScraperValidator scraperValidator)
 {
     _profileDao       = profileDao;
     _scraperSettings  = scraperSettings;
     _scraperValidator = scraperValidator;
 }