public async void TotalDePublicacoes(string username, IInstaApi api) { IResult <InstaUser> userSearch = await api.GetUserAsync(username); Console.WriteLine($"USER:{userSearch.Value.FullName}\n\tFollowers: {userSearch.Value.FollowersCount}\n\t {userSearch.Value.IsVerified}"); IResult <InstaMediaList> media = await api.GetUserMediaAsync(username, PaginationParameters.MaxPagesToLoad(5)); List <InstaMedia> mediaList = mediaList = media.Value.ToList(); for (int i = 0; i < mediaList.Count; i++) { InstaMedia m = mediaList[i]; if (m != null && m.Caption != null) { string captionText = m.Caption.Text; if (captionText != null) { if (m.MediaType == InstaMediaType.Image) { for (int X = 0; X < m.Images.Count; X++) { if (m.Images[X] != null && m.Images[X].URI != null) { Console.WriteLine($"\n\t{captionText}"); string uri = m.Images[X].URI; Console.Write($"{uri}\n\t"); } } } } } } }
public static async void Subs(string userExp, string userName, string password) { user = new UserSessionData(); user.UserName = userName; user.Password = password; api = InstaApiBuilder.CreateBuilder() .SetUser(user) .UseLogger(new DebugLogger(LogLevel.Exceptions)) //.SetRequestDelay(TimeSpan.FromSeconds(1)) .Build(); var loginRequest = await api.LoginAsync(); IResult <InstaUser> userSearch = await api.GetUserAsync(userExp); IResult <InstaUserShortList> followers = await api.GetUserFollowersAsync(userSearch.Value.UserName, PaginationParameters.MaxPagesToLoad(5)); var followlist = followers.Value; int count_followlist = followlist.ToArray().Length; for (int i = 0; i < count_followlist; i++) { var res = await api.FollowUserAsync(followlist[i].Pk); string result = res.Succeeded.ToString(); } }
private async void ButtonBase_OnClick(object sender, RoutedEventArgs e) { IResult <InstaUserInfo> userinfo = await _instaApi.GetUserInfoByIdAsync(_userSession.LoggedInUder.Pk); IResult <InstaUser> user = await _instaApi.GetUserAsync("aeroflot"); IResult <InstaUserInfo> info = await _instaApi.GetUserInfoByIdAsync(user.Value.Pk); IResult <InstaUserShortList> folows = await _instaApi.GetUserFollowersAsync(_userSession.UserName, PaginationParameters.Empty); IResult <InstaMedia> userinfo2 = await _instaApi.GetMediaByIdAsync(folows.Value[43].ProfilePictureId); using (HttpClient client = new HttpClient()) { HttpResponseMessage imageResponse = await client.GetAsync(userinfo2.Value.Images[0].URI); //InMemoryRandomAccessStream randomAccess = new InMemoryRandomAccessStream(); //DataWriter writer = new DataWriter(randomAccess.GetOutputStreamAt(0)); //writer.WriteBytes(await imageResponse.Content.ReadAsByteArrayAsync()); //await writer.StoreAsync(); //BitmapImage bm = new BitmapImage(); //await bm.SetSourceAsync(randomAccess); //myImg.Source = bm; } }
public static async void Like(string userExp, string userName, string password) { user = new UserSessionData(); user.UserName = userName; user.Password = password; api = InstaApiBuilder.CreateBuilder() .SetUser(user) .UseLogger(new DebugLogger(LogLevel.Exceptions)) //.SetRequestDelay(TimeSpan.FromSeconds(1)) .Build(); var loginRequest = await api.LoginAsync(); IResult <InstaUser> userSearch = await api.GetUserAsync(userExp); IResult <InstaMediaList> media = await api.GetUserMediaAsync(userExp, PaginationParameters.MaxPagesToLoad(5)); var mediaList = media.Value; int count_mediaList = mediaList.ToArray().Length; for (int i = 0; i < count_mediaList; i++) { var res = await api.LikeMediaAsync(mediaList[i].InstaIdentifier); string result = res.Succeeded.ToString(); } }
public static async void PullUserPosts(string userToScrape) { Console.WriteLine("Wait"); IResult <InstaUser> userSearch = await api.GetUserAsync(userToScrape); Console.WriteLine(userSearch.ToString()); Console.WriteLine("done"); }
public async Task <IResult <InstaUser> > Verify(string code) { var verifyResult = await _api.SendVerifyCode(code); //verify from sms-online and other... //selen.RemoveInstagramNumber(); var res = await _api.ResetChallenge(); return(await _api.GetUserAsync("_sit.com_")); //TODO: log }
public async void ScrapeUser(string username) { //followers.Add(username); //Console.WriteLine("############################## USER {0} ###################################", username); //IResult<InstaUser> userSearch = await api.GetUserAsync(username); var task = api.GetUserAsync(username); IResult <InstaUser> userSearch = task.GetAwaiter().GetResult(); Thread.Sleep(2000); //Console.WriteLine($"USER: {userSearch.Value.FullName}\n\tUserName: {userSearch.Value.UserName}\n\tFollowers: {userSearch.Value.FollowersCount}\n\tVerified: {userSearch.Value.IsVerified}\n\tBio: {userSearch.Value.FollowersCount}"); //IResult<InstaUserInfo> userInfo = await api.GetUserInfoByUsernameAsync(username); var task1 = api.GetUserInfoByUsernameAsync(username); IResult <InstaUserInfo> userInfo = task1.GetAwaiter().GetResult(); Thread.Sleep(2000); //Console.WriteLine($"BioGraphy: {userInfo.Value.Biography}"); string phone = "", eMail = ""; foreach (var line in userInfo.Value.Biography.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)) { string phoneNumber = GetPhoneNumber(line); phone = phoneNumber; const string MatchEmailPattern = @"(([\w-]+\.)+[\w-]+|([a-zA-Z]{1}|[\w-]{2,}))@" + @"((([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\." + @"([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])){1}|" + @"([a-zA-Z]+[\w-]+\.)+[a-zA-Z]{2,4})"; Regex rx = new Regex(MatchEmailPattern, RegexOptions.Compiled | RegexOptions.IgnoreCase); MatchCollection matches = rx.Matches(line); int noOfMatches = matches.Count; foreach (Match match in matches) { if (string.IsNullOrEmpty(eMail)) { eMail = match.Value.ToString(); } else { eMail += "," + match.Value.ToString(); } } } if (!string.IsNullOrEmpty(eMail)) { User usr = new User(userSearch.Value.FullName, eMail, userSearch.Value.UserName, phone); users.Add(usr); } }
public async Task <InstaUserShort> GetUserByUserName(string username) { var user = (await _instaApi.GetUserAsync(username)).Value; return(new InstaUserShort() { FullName = user.FullName, UserName = user.UserName, IsPrivate = false, IsVerified = false, Pk = user.Pk, ProfilePicture = user.ProfilePicture, ProfilePictureId = user.ProfilePictureId }); }
private static async void Bot_OnMessage(object sender, MessageEventArgs e) { Console.WriteLine("Bot proccessing datas...\n*"); System.Threading.Thread.Sleep(5000); //login side var logged = await api.LoginAsync(); var loginRequest = await api.LoginAsync(); if (logged.Succeeded) { IResult <InstaUser> userSearch = await api.GetUserAsync(user.UserName); //Console.WriteLine(string.Format("User: {0} \n\t Followers: {1} \n\t \n\t Verifeid: {2}", userSearch.Value.FullName, userSearch.Value.FollowersCount, userSearch.Value.IsVerified)); IResult <InstaMediaList> media = await api.GetUserMediaAsync(user.UserName, PaginationParameters.MaxPagesToLoad(6)); List <InstaMedia> mediaList = media.Value.ToList(); //get posts from instagram and send to telegram bot side for (int i = 0; i < mediaList.Count; i++) { InstaMedia m = mediaList[i]; if (m != null && m.Caption != null) { string captionText = m.Caption.Text; if (captionText != null) { if (m.MediaType == InstaMediaType.Image && m.Images[i].URI != null && m.Images[i].URI != null) { //getting img url string uri = m.Images[i].URI; string info = mediaList[i].InstaIdentifier; int hashDecode = mediaList[i].GetHashCode(); //System.Console.WriteLine(Convert.ToString(i + 1) + ".nci POST IMG ->" + info + " " + uri + "\n" + "\n\t hashcode: " + hashDecode); //System.Console.WriteLine(Convert.ToString(i + 1) + ".nci POST MASSEGE -> " + captionText + "\n"); System.Threading.Thread.Sleep(3000); //Telegram bot if (e.Message.Text != null && e.Message.Text.ToLower() == "getir") { Console.WriteLine($"Last message -> {e.Message.Chat.Id}."); //Send Message Message message = await botClient.SendTextMessageAsync( chatId : e.Message.Chat, text : captionText, parseMode : ParseMode.Markdown, disableNotification : true, //replyToMessageId: e.Message.MessageId, replyMarkup : new InlineKeyboardMarkup(InlineKeyboardButton.WithUrl( "", "https://core.telegram.org/bots/api#sendmessage" )) ); //Send Image Message photo = await botClient.SendPhotoAsync( chatId : e.Message.Chat, photo : uri, parseMode : ParseMode.Html ); } } } } } } }//Instagram get data
public static async void Routes(string UserName, int Delay) { _instaAPI = InstaApiBuilder.CreateBuilder() .SetUser(UserSessionData) .UseLogger(new DebugLogger(LogLevel.Exceptions)).Build(); var request = await _instaAPI.LoginAsync(); var userId = File.ReadAllLines("Users.txt").ToList(); if (request.Succeeded) { Console.ForegroundColor = ConsoleColor.Yellow; Log.Push($"Успешная авторизация: {UserName}"); while (true) { try { var user = await _instaAPI.GetUserAsync( userId[Random.Next(0, userId.Count)]); var message = File.ReadAllLines("messages.txt").ToList(); if (message.Count == 0) { Console.ForegroundColor = ConsoleColor.Red; Log.Push("Отсутствуют фразы."); break; } if (userId.Count == 0 || !File.Exists("Users.txt")) { Console.ForegroundColor = ConsoleColor.Red; Log.Push("База пользователей отсутствует или ещё не была содана."); break; } if (user.Value != null) { var sendMessage = await _instaAPI.SendDirectMessage(user.Value.Pk.ToString(), null, message[Random.Next(0, message.Count)]); Console.ForegroundColor = ConsoleColor.Cyan; if (sendMessage.Succeeded) { Log.Push($"Сообщение было успешно отправлено на аккаунте: {UserName}"); } else { Console.ForegroundColor = ConsoleColor.Red; Log.Push($"Ошибка при отправке сообщения:\n\tАккаунт: {UserName}\n\tСообщение {user.Info.Message}"); } } Thread.Sleep(Delay); } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Log.Push($"Неизвестная ошибка: {ex.Message}"); _instaAPI = null; } } } else { Log.Push($"Ошибка авторизации: {request.Info.Message}"); } }