Study/개발 Tip

[개발 TIP] 코딩으로 Instagram 팔로우를 늘려보자!

AC 2021. 4. 18. 03:49

 

예를 들어 밈 페이지를 사용할 것입니다. 밈 페이지 커뮤니티에서 관리자가 다른 유사한 밈 페이지를 팔로우 한 다음 나중에 팔로우 해제하는 사용자를 팔로우하는 것은 매우 일반적인 관행입니다. 이 전략의 기본 전제는 아웃 리치입니다. 그렇지 않으면 귀하의 페이지를 보지 못했을 사람들은 결국 그것을보고, 그들이 그것을 좋아한다면, 그들은 당신을 뒤 따르고 콘텐츠를 위해 당신을 계속 따라갈 것입니다. 페이지가 마음에 들지 않으면 뒤를 따르지 않고 별거 아닙니다. 이것은 괜찮은 전략이지만 수천 명의 사람들을 수동으로 팔로우하는 데는 꽤 오랜 시간이 걸립니다. 그래서 우리는이 프로세스를 자동화하고 최적화 할 것입니다!실제

Instagram API가 있습니다. 5

이지만 모바일 앱을 통해서만 액세스 할 수 있습니다. 좋습니다. 오픈 소스

Python 라이브러리도 있습니다. 31

Github에서 스크립트를 모바일 앱으로 마스킹하고 API 호출에 HTTP 요청을 사용하여 Instagram API에 액세스 할 수 있습니다.따라서 git pull을 사용하여 라이브러리에 다운로드 한 후 작동하는지 테스트하여 시작할 수 있습니다. 여기서는이 스크립트를 사용하여 로그인하고 자체 데이터를 인쇄합니다.
from instabot import Bot

bot = Bot();

my_username = " ";
my_password = " "; #fill in with IG credentials

bot.login(username = my_username, password = my_password);

user_id = bot.get_user_id_from_username(my_username);

user_info = bot.get_user_info(user_id);

print(user_info);

 

 

멋지네요. 작동합니다.이제 다음 메서드를 작성했습니다.
def follow(bot, followers, followCount, amt):
    lower = followCount;
    #upper = min(followCount + amt, len(followers));
    count = 0;
    actualCount = 0;
    #follow
    for user in followers[lower:]: 
        print("count", count);
        print("amt", amt);
        if count >= amt:
            return actualCount;
        username = bot.get_username_from_user_id(user);     
        #print("Attempting to follow:", username);
        if bot.follow(username):
            print("Followed! -", username);
            count += 1;
        else:
            print("Not Followed! -", username);
        actualCount += 1;
        
    return actualCount;
테스트 스크립트로 이것을 실행하면 성공적으로 진행되고 배열의 사용자를 따라가는 것을 볼 수 있습니다.

 

그런 다음 unfollowing 메서드를 작성하면 배열에서 사용자를 성공적으로 언 팔로우 할 수 있습니다.
def unfollow(bot, amt):
    following = bot.get_user_following("");
    whitelist = bot.whitelist_file;
    following = list(set(following) - whitelist.set);
    i = 0;
    cap = min(100, len(following));
    for user in following[:-cap]: #get_user_following stored in reverse stack
        if bot.api.last_response.status_code == 400:
            sys.exit();
        username = bot.get_username_from_user_id(user);
        print("Attempting to unfollow:", username);
        if bot.unfollow(username):
            i += 1;
            print("Unfollowed -", username);
        else:
            print("Failed to unfollow -", username);
        if(i >= amt):
            break;
    return True;
Instagram의 시간당 160 명의 사용자를 팔로우 / 언 팔로우하는 제한으로, 우리는 1 시간 슬롯에 160 명에 대해 팔로우 방법을 실행 한 다음 다른 1 시간 슬롯에 160 명에 대해 언 팔로우 방법을 실행하고 이것을 반복 할 것입니다. 우리가 사람들 을 팔로우 할 때 우리는 팔로우 목록끝에 그들의 ID를 추가하고 ,
 
팔로우 해제 할 때 팔로우 목록의 시작부터 언 팔로우하기를 원 하므로 우리가 방금 팔로우 한 사람들을 언 팔로우하지 않습니다. 따라 갔다. 이렇게하면 고객이 우리 계정을 확인하고 원할 경우 다시 팔로우 할 수있는 충분한 시간이 있습니다.우리는 또한 단지 시작하기 위해 밈 페이지와 같은 단일 계정의 배열을 제공 할 것입니다. 결국, 영원히 자율적으로 실행하기 위해 우리와 같은 다른 밈 페이지를 크롤링하고 찾을 수 있지만 다음 단계에 있습니다.
amt = 160;
delay = 600;
for acc in accounts:
    followers = bot.get_user_followers(acc);
    skipped = bot.skipped_file;
    followed = bot.followed_file;
    unfollowed = bot.unfollowed_file;
    followers = list(set(followers) - skipped.set - followed.set - unfollowed.set);
    followCount = 0;
    printUpdate("Starting Running")
    while followCount < len(followers):
        startTime = printUpdate("Starting Following")
        followCount += follow(bot, followers, followCount, amt);
        endTime = printUpdate("Ending Following")
        secElapsed = (endTime - startTime).total_seconds();
        if secElapsed < 3600:
            sleep(3600 - secElapsed);
        startTime = printUpdate("Starting UnFollowing")
        unfollow(bot,amt);
        endTime = printUpdate("Ending UnFollowing")
        secElapsed = (endTime - startTime).total_seconds();
        if secElapsed < 3600:
            sleep(3600 - secElapsed);
                    
    accCount += 1;
이제 필터를 추가하여 하나의 계정을 팔로우하는 사용자에게 다가가는 것 이상으로 지속 가능하도록하겠습니다. 우리는 그 과정에서 우리가 누구를 팔로우하고 있는지 살펴볼 것이며, 그들이 우리와 같은 다른 밈 페이지라면 (밈 페이지도 서로를 따르기 때문에), 우리는 우리의 계정 목록에 추가 할 것입니다. 루프에서 다시 실행됩니다. 이렇게하면 거의 영원히 실행할 수 있습니다.
def filter(bot, amt):
    following = bot.get_user_following("");
    whitelist = bot.whitelist_file;
    following = list(set(following) - whitelist.set);
    added = 0;
    for user in following[-amt:]: #file read is stored in reversed stack
        if bot.api.last_response.status_code == 400:
            sys.exit();
        username = bot.get_username_from_user_id(user);
        user_info = bot.get_user_info(user)
        bio = user_info['biography'];
        username = user_info['username'];
        name = user_info['full_name'];
        followers = user_info['follower_count'];
        following = user_info['following_count'];
        if "meme" in bio.lower() or "meme" in name.lower() or "meme" in username.lower():
            if followers > 2500 and followers < 10000:
                if following/followers < 4:
                    accounts.append(username);
                    print("Added: ", username);
                    added += 1;
        if added >= 3:
            return;
        sleep(round(random.uniform(4,7), 2));
...
    while followCount < len(followers):
    ...
        if(len(accounts) - accCount < 2):
            startTime = printUpdate("Starting Filter");
            filter(bot, 400);
            endTime = printUpdate("Ending Filter");
            secElapsed = (endTime - startTime).total_seconds();
            if secElapsed < 3600:
                sleep(3600 - secElapsed);
그래, 그게 다야! Instagram 성장을 자동화했습니다! 나는 이것을 내 페이지에서 실행했고, 160 명마다 스크립트가 팔로우하고 약 50 명이 나를 따라 왔다는 것을 발견했습니다. 2,000 명의 팔로워가있을 때 스크립트를 실행하기 시작했고이를 통해 내 콘텐츠를 즐기는 5,000 명 이상의 실제 활동적인 팔로워를 확보 할 수있었습니다.
 
내 페이지의 목표는 사람들을 웃고 행복하게 만드는 것입니다.
그래서 더 많은 사람들을 위해 그렇게 할 수 있다면 꽤 멋지다고 생각합니다.인스 타 그램이 프로세스를 감지하면이 작업을 수행하는 계정을 차단한다는 점을 경고해야하므로 매우주의해야합니다.도서관에서 직접 해보십시오

 

LIST