public async Task RunAsync() { _logger.LogTrace("RunAsync()"); await _seleniumWrapper.ScrollToTopAsync(); // open await _seleniumWrapper.Click(_instagramOptions.CssHeaderButtonActivity); // close, a hidden div will catch the click but we usea click by position so it will work for selenium await _seleniumWrapper.Click(_instagramOptions.CssHeaderButtonActivity); }
public async Task RunAsync() { _logger.LogTrace("RunAsync()"); // open profile await _seleniumWrapper.Click(_instagramOptions.CssHeaderMyself); await _seleniumWrapper.Click(_instagramOptions.CssHeaderMyselfProfile); // must be here, else the auth have failed // open followers popup await _seleniumWrapper.Click(_instagramOptions.CssContactsFollowers); // find int followDone = 0; int followTodo = PseudoRandom.Next(_followBackOptions.FollowMin, _followBackOptions.FollowMax); IWebElement element = _seleniumWrapper.GetElement(_instagramOptions.CssFollowerFollowable, canBeMissing: true); while (element != null && followDone < followTodo) { // like _logger.LogDebug("Following"); await _seleniumWrapper.ScrollIntoView(element, thenWait : false); // bigger waiter altready present after await _waitAction.PreFollowWait(); await _seleniumWrapper.Click(element); _seleniumWrapper.CrashIfPresent(_instagramOptions.CssActionWarning, InstagramOptions.CssActionWarningErrorMessage); followDone++; // prepare next element = _seleniumWrapper.GetElement(_instagramOptions.CssFollowerFollowable, canBeMissing: true); } if (followDone == followTodo) { _logger.LogDebug("Follow back actions : {0} follow", followDone); } else { _logger.LogInformation("Follow back actions : {0}/{1} follow (not all done, seem not any more user to follow back)", followDone, followTodo); } // close the popup await _seleniumWrapper.Click(_instagramOptions.CssContactsClose); throw new NotImplementedException(); }
public async Task RunAsync() { _logger.LogTrace("RunAsync()"); await _seleniumWrapper.ScrollToTopAsync(); // open await _seleniumWrapper.Click(_instagramOptions.CssHeaderButtonHome); // scrools await _seleniumWrapper.ScrollToBottomAsync(_homePageActionsOptions.InitScrools); // find int likeDone = 0; int likeTodo = DoLike ? PseudoRandom.Next(_homePageActionsOptions.LikeMin, _homePageActionsOptions.LikeMax) : 0; IWebElement element = _seleniumWrapper.GetElement(_instagramOptions.CssPhotoLike, canBeMissing: true); while (element != null && likeDone < likeTodo) { // like _logger.LogDebug("Liking"); await _seleniumWrapper.ScrollIntoView(element, thenWait : false); // bigger waiter alredy present after await _waitAction.PreLikeWait(); await _seleniumWrapper.Click(element); _seleniumWrapper.CrashIfPresent(_instagramOptions.CssActionWarning, InstagramOptions.CssActionWarningErrorMessage); likeDone++; // prepare next await _seleniumWrapper.ScrollToBottomAsync(); element = _seleniumWrapper.GetElement(_instagramOptions.CssPhotoLike, canBeMissing: true); } if (likeDone == likeTodo) { _logger.LogDebug("Home page actions : {0} like", likeDone); } else { _logger.LogWarning("Home page actions : {0}/{1} liked (not all done, you may increase scrool or reduce frequency)", likeDone, likeTodo); } }
private async Task AuthLoginAsync() { _logger.LogTrace("AuthLoginAsync()"); // Ignore the message bar : Allow Instagram Cookies await _seleniumWrapper.Click(_instagramOptions.CssCookiesWarning, canBeMissing : true); await _seleniumWrapper.InputWriteAsync(_instagramOptions.CssLoginEmail, _loggingOptions.User); if (!string.IsNullOrWhiteSpace(_loggingSecretOptions.Password)) { await _seleniumWrapper.InputWriteAsync(_instagramOptions.CssLoginPassword, _loggingSecretOptions.Password); await _seleniumWrapper.EnterKeyAsync(_instagramOptions.CssLoginPassword); } else { _logger.LogInformation("Waiting user manual password validation..."); _logger.LogWarning("PRESS <ENTER> WHEN LOGGED"); Console.ReadLine(); } // Humain user need to login with email code check ? In this case, remove password from the config and increase a lot step time (~1min) in order to allow you to pass throu this check process _seleniumWrapper.CrashIfPresent(_instagramOptions.CssLoginUnusual, InstagramOptions.CssLoginUnusualErrorMessage); // Confirm save user info await _seleniumWrapper.Click(_instagramOptions.CssLoginSageInfo, canBeMissing : true); // Ignore the enable notification on your browser modal popup await _seleniumWrapper.Click(_instagramOptions.CssLoginWarning, canBeMissing : true); // who am i ? await _seleniumWrapper.Click(_instagramOptions.CssHeaderMyself); // must be here, else the auth have failed await _seleniumWrapper.Click(_instagramOptions.CssHeaderMyselfProfile); // must be here, else the auth have failed // new session with user URL _persistenceManager.SetNewSession(_seleniumWrapper.CurrentUrl); _logger.LogDebug("User {0} authentified from password : {1}", _loggingOptions.User, _persistenceManager.Session.UserContactUrl); }
public async Task RunAsync() { _logger.LogTrace("RunAsync()"); await _seleniumWrapper.ScrollToTopAsync(); // open if require if (_seleniumWrapper.CurrentUrl != _persistenceManager.Session.UserContactUrl) { await _seleniumWrapper.Click(_instagramOptions.CssHeaderMyself); await _seleniumWrapper.Click(_instagramOptions.CssHeaderMyselfProfile); // must be here, else the auth have failed } // need to get a new list HashSet<string> myFollowers = await GetMyFollowers(); // open Following popup await _seleniumWrapper.Click(_instagramOptions.CssContactsFollowing); // loop until no more element await _seleniumWrapper.ScrollToBottomAsync(_instagramOptions.CssContactsListScrollable); // Get the list HashSet<string> myFollowing = new HashSet<string>(_seleniumWrapper.GetAttributes(_instagramOptions.CssContactUrl)); myFollowing.ExceptWith(myFollowers); _logger.LogDebug("Found {0} currently followed but not follower", myFollowing.Count); // find int unfollowDone = 0; int unfollowTodo = PseudoRandom.Next(_unfollowUnfollowersOptions.UnfollowMin, _unfollowUnfollowersOptions.UnfollowMax); IWebElement element = GetNextElement(myFollowing); while (element != null && unfollowDone < unfollowTodo) { _logger.LogDebug("Unfollowing"); // Unfollowing popup await _seleniumWrapper.ScrollIntoView(element, thenWait: false); // bigger waiter altready present after await _waitAction.PreFollowWait(); await _seleniumWrapper.Click(element); // Unfollowing action await _seleniumWrapper.Click(_instagramOptions.CssContactUnfollowConfirm); _seleniumWrapper.CrashIfPresent(_instagramOptions.CssActionWarning, InstagramOptions.CssActionWarningErrorMessage); unfollowDone++; // prepare next element = GetNextElement(myFollowing); } if (unfollowDone == unfollowTodo) { _logger.LogDebug("Unfollow actions : {0} unfollowed", unfollowDone); } else { _logger.LogDebug("Unfollow actions : {0}/{1} unfollowed (not all done, seem not any more user to unfollow)", unfollowDone, unfollowTodo); } // close the popup await _seleniumWrapper.Click(_instagramOptions.CssContactsClose); }
public async Task RunAsync() { _logger.LogTrace("RunAsync()"); await _seleniumWrapper.ScrollToTopAsync(); // open await _seleniumWrapper.Click(_instagramOptions.CssHeaderButtonExplore); // Wait loading if required await _seleniumWrapper.WaitLoader(_instagramOptions.CssExploreLoading); // scrools await _seleniumWrapper.ScrollToBottomAsync(_explorePhotosPageActionsOptions.InitScrools); // find int followDone = 0; int likeDone = 0; int followTodo = DoFollow ? PseudoRandom.Next(_explorePhotosPageActionsOptions.FollowMin, _explorePhotosPageActionsOptions.FollowMax) : 0; int likeTodo = DoLike ? PseudoRandom.Next(_explorePhotosPageActionsOptions.LikeMin, _explorePhotosPageActionsOptions.LikeMax) : 0; IWebElement element = _seleniumWrapper.GetElement(_instagramOptions.CssExplorePhotos); while (element != null && (likeDone < likeTodo || followDone < followTodo)) { _logger.LogDebug("Opening a post"); await _seleniumWrapper.ScrollIntoView(element); await _seleniumWrapper.Click(element); // TOFIX : In some case, the popup seem to fail to open and then _seleniumWrapper.Click(_instagramOptions.CssPhotoClose); will fail or click on the current customer icon and open user profil, next actions will faild then // Follow if (followDone < followTodo && _seleniumWrapper.GetElementIfPresent(_instagramOptions.CssPhotoFollow, out IWebElement btnFollow)) { _logger.LogDebug("Following"); await _waitAction.PreFollowWait(); await _seleniumWrapper.Click(btnFollow); _seleniumWrapper.CrashIfPresent(_instagramOptions.CssActionWarning, InstagramOptions.CssActionWarningErrorMessage); followDone++; } // like if (likeDone < likeTodo && _seleniumWrapper.GetElementIfPresent(_instagramOptions.CssPhotoLike, out IWebElement btnLike)) { _logger.LogDebug("Liking"); await _waitAction.PreLikeWait(); await _seleniumWrapper.Click(btnLike); _seleniumWrapper.CrashIfPresent(_instagramOptions.CssActionWarning, InstagramOptions.CssActionWarningErrorMessage); likeDone++; } // close modal page without waiter await _seleniumWrapper.Click(_instagramOptions.CssPhotoClose); // prepare next await _seleniumWrapper.ScrollToBottomAsync(); element = _seleniumWrapper.GetElement(_instagramOptions.CssExplorePhotos); } if (likeDone == likeTodo) { _logger.LogDebug("Explore Photos page actions : {0} like, {1} follow", likeDone, followDone); } else { _logger.LogWarning("Explore Photos page actions : {0}/{1} like, {2}/{3} follow (not all done, you may increase scrool or reduce frequency)", likeDone, likeTodo, followDone, followTodo); } }