public override void Process(BotStateBuilder botState)
        {
            if (!_loadResultsFromFile)
            {
                //Gets values from another components
                _searchResults =
                    (Dictionary <string, List <string> >)
                    botState.ComponentsDataHandler[typeof(SearchResultsScannerComponent).Name];
            }
            else
            {
                _searchResults = SerDeUtils.DeserializeJsonFile <Dictionary <string, List <string> > >(Path.Combine(_baseDir, _searchResultsFileName));
            }
            Wait wait = new Wait(botState.Driver);

            foreach (var searchResult in _searchResults)
            {
                foreach (var userProfile in searchResult.Value)
                {
                    _userProfilePage.SetPageUrl(userProfile);
                    Thread.Sleep(400);
                    _userProfilePage.GoToPageUrl();

                    var currentProfileDataPath = Path.Combine(_baseDir, "AllProfiles", searchResult.Key, Path.GetFileName(userProfile));
                    Directory.CreateDirectory(currentProfileDataPath);

                    //Get Profile info
                    GetProfileInfo(Path.Combine(currentProfileDataPath, "ProfileInfo.json"));
                    Configs.Logger.Debug($"Profile info was gathered | Profile: {userProfile}");

                    if (_postsCount != 0)
                    {
                        //Get Profile posts
                        GetProfilePosts(Path.Combine(currentProfileDataPath, "Posts.json"));
                        Configs.Logger.Debug($"Posts was gathered | Profile: {userProfile}");
                    }

                    if (_profilePhotosCount != 0 || _galleryPhotosCount != 0)
                    {
                        //Get All kind of photos
                        OpenAlbumViewForGettingPhotos(currentProfileDataPath);
                    }

                    Configs.Logger.Info($"Profile inteligence succed! Profile: {userProfile} | Search marker: {searchResult.Key}");
                }
            }
        }
示例#2
0
 public BotLoader(List <BotComponent> components, Type driverType = null, string botStateBackupDir = null,
                  bool loadFromBackup = false)
 {
     _components        = components;
     _loadFromBackup    = loadFromBackup;
     _botStateBackupDir = botStateBackupDir;
     _botStateFileName  = "BotStateBuilder.state";
     _botState          = new BotStateBuilder(driverType);
     if (!loadFromBackup == false)
     {
         if (!String.IsNullOrEmpty(_botStateBackupDir))
         {
             _botState =
                 SerDeUtils.DeserializeJsonFile <BotStateBuilder>(Path.Combine(_botStateBackupDir, _botStateFileName));
             _logger.Info($"BotState loaded from {_botStateFileName}");
         }
         else
         {
             _logger.Warn($"Can't find state file on path:{_botStateBackupDir}");
         }
     }
 }
 public override void Prepare(BotStateBuilder botState)
 {
     _searchLinks       = SerDeUtils.DeserializeJsonFile <Dictionary <string, string> >(LinksInputPath);
     _searchResults     = new Dictionary <string, List <string> >();
     _searchResultsPage = new SearchResultsPage(botState.Driver);
 }