示例#1
0
        public override List <InstagramConnection> GetFilteredConnections(List <InstagramConnection> connections)
        {
            var filteredConnections = new List <InstagramConnection>();

            foreach (var connection in connections)
            {
                var connectionUrl = connection.Item;

                if (!_scraperValidator.StringContainsMaleFirstName(connectionUrl.CleanQueueItem()) &&
                    !_scraperValidator.StringContainsMaleUsername(connectionUrl.CleanQueueItem()) &&
                    !_scraperValidator.StringContainsAnythingBad(connectionUrl) &&
                    !_scraperValidator.StringContainsAnythingBad(connectionUrl.CleanQueueItem()))
                {
                    filteredConnections.Add(connection);
                }
            }

            return(filteredConnections);
        }
        public bool ShouldScrape(out ValidationResult validationResult)
        {
            if (_scraperSettings["ignore_profiles_with_male_username"] == "1" && _scraperValidator.StringContainsMaleUsername(Username.CleanQueueItem()))
            {
                validationResult = ValidationResult.UsernameContainsMaleName;
                return(false);
            }

            if (_scraperSettings["ignore_profiles_with_male_name"] == "1" && _scraperValidator.StringContainsMaleFirstName(Name.CleanQueueItem()))
            {
                validationResult = ValidationResult.NameContainsMaleName;
                return(false);
            }

            if (_scraperSettings["ignore_profiles_with_foreign_bio"] == "1" && _scraperValidator.IsStringForeign(Bio))
            {
                validationResult = ValidationResult.StringIsForeign;
                return(false);
            }

            if (_scraperSettings["ignore_profiles_with_foreign_name"] == "1" && _scraperValidator.IsStringForeign(Name))
            {
                validationResult = ValidationResult.StringIsForeign;
                return(false);
            }

            if (_scraperSettings["ignore_profiles_with_male_snap_username"] == "1" && SnapchatFound && !string.IsNullOrEmpty(SnapchatUsername) && _scraperValidator.StringContainsMaleUsername(SnapchatUsername))
            {
                validationResult = ValidationResult.SnapchatUsernameContainsMaleName;
                return(false);
            }

            if (AgeGuessed >= 12 && AgeGuessed < int.Parse(_scraperSettings["minimum_age_to_scrape_profile"]))
            {
                validationResult = ValidationResult.MinimumAgeNotMet;
                return(false);
            }

            if (_scraperSettings["ignore_profiles_with_promotion_bio"] == "1" && _scraperValidator.StringContainsPromotion(Bio))
            {
                validationResult = ValidationResult.BioContainsPromotion;
                return(false);
            }

            if (_scraperValidator.StringContainsDeletedProfilePhrase(Username)) // TODO: Only check depending on a config value?
            {
                validationResult = ValidationResult.UsernameContainsDeletedProfilePhrase;
                return(false);
            }

            if (_scraperValidator.StringContainsMakeUpPhrase(Username)) // TODO: Only check depending on a config value?
            {
                validationResult = ValidationResult.UsernameContainsMakeUpPhrase;
                return(false);
            }

            if (Username.Length < 7)
            {
                validationResult = ValidationResult.UsernameTooShort;
                return(false);
            }

            if (Username.Length > 25)
            {
                validationResult = ValidationResult.UsernameTooLong;
                return(false);
            }

            if (Name.Length < 4)
            {
                validationResult = ValidationResult.NameTooShort;
                return(false);
            }

            if (Name.Length > 30)
            {
                validationResult = ValidationResult.NameTooLong;
                return(false);
            }

            if (_scraperValidator.StringContainsGenericBadPhrase(Bio))
            {
                validationResult = ValidationResult.BioContainsBadPhrase;
                return(false);
            }

            validationResult = ValidationResult.Success;
            return(true);
        }