Sign inSign up

funkypenguin/instapy

By funkypenguin

β€’Updated almost 8 years ago

Alpine version of https://github.com/timgrossmann/InstaPy for deployment in Swarm

Image
10

50K+

funkypenguin/instapy repository overview

⁠InstaPy

MIT license built with Selenium built with Python3 Travis

⁠Automation Script for β€œfarming” Likes, Comments and Followers on Instagram

Implemented in Python using the Selenium module.

Think this tool is worth supporting? Head over to https://github.com/timgrossmann/InstaPy/wiki/How-to-Contribute⁠ to find out how you can help. Become a part of InstaPy!

Have an issue? Head over to https://github.com/timgrossmann/InstaPy/wiki/Reporting-An-Issue⁠ to find out how to report this to us and get help.

Disclaimer: Please Note that this is a research project. I am by no means responsible for any usage of this tool. Use on your own behalf. I'm also not responsible if your accounts get banned due to extensive use of this tool.

⁠Newsletter: SignUp for the Newsletter here!⁠
⁠Social
⁠InstaPy Twitter⁠ | My Twitter⁠ | How it works (Medium)⁠ |

Talk about automating your Instagram⁠ | Talk about doing Open-Source work⁠ | Listen to the "Talk Python to me"-Episode⁠

⁠Do you need help ?

Discord channel

⁠Do you want to support us ?
⁠
paypalme ⁠

⁠Table of Contents

⁠Getting started

⁠Video tutorials:

Setting up InstaPy for MacOS using Firefox⁠

Setting up InstaPy at Digital Ocean (for Debian)⁠

Setting up InstaPy for Windows⁠

⁠Guides:

How to Ubuntu (64-Bit)⁠       

How to RaspberryPi⁠       

How to Windows⁠

⁠Basic Installation:
1. git clone https://github.com/timgrossmann/InstaPy.git
2. cd InstaPy
3. pip install .
or
3. python setup.py install
  1. Download chromedriver for your system from here⁠. Extract the .zip file and put it in /assets folder.
⁠Preferred Installation:

The best way to install InstaPy is to create a virtual enviornment, install InstaPy there and run it from a separate file:

⁠Python >= 3.6
⁠Mac/Linux
1. git clone https://github.com/timgrossmann/InstaPy.git
2. cd InstaPy
3. python3 -m venv venv
4. source venv/bin/activate
5. pip install .
⁠Windows
1. git clone https://github.com/timgrossmann/InstaPy.git
2. cd InstaPy
3. python3 -m venv venv
4. venv\Scripts\activate.bat
5. pip install .

If you're not familiar with venv, please read about it here⁠ and use it to your advantage. Running source venv/bin/activate will activate the correct Python to run InstaPy. To exit an activated venv run deactivate. Now, copy/paste the quickstart.py Python code below and run your first InstaPy script. Remember to run it with Python from the venv. To make sure which Python is used, run which python, it will tell you which Python is 'active'. Whenever you run the script, the virtual enviornment must be active.

⁠Python < 3.6
1. virtualenv venv
2. source venv/bin/activate
3. pip install git+https://github.com/timgrossmann/InstaPy.git

If you're not familiar with virtualenv, please read about it here⁠ and use it to your advantage. In essence, this is be the only Python library you should install as root (e.g., with sudo). All other Python libraries should be inside a virtualenv. Running source venv/bin/activate will activate the correct Python to run InstaPy. To exit an activated virtualenv run deactivate. Now, copy/paste the quickstart.py Python code below and run your first InstaPy script. Remember to run it with Python from the virtualenv, so from venv/bin/python. To make sure which Python is used, run which python, it will tell you which Python is 'active'.

⁠Set it up yourself with this Basic Setup

Basic setup is a good way to test the tool. At project root folder open quickstart.py and update with your username and password.

from instapy import InstaPy
from instapy.util import smart_run

# login credentials
insta_username = ''
insta_password = ''

# get an InstaPy session!
# set headless_browser=True to run InstaPy in the background
session = InstaPy(username=insta_username,
                  password=insta_password,
                  headless_browser=False)

with smart_run(session):
    """ Activity flow """
    # settings
    session.set_relationship_bounds(enabled=True,
                                    delimit_by_numbers=True,
                                    max_followers=4590,
                                    min_followers=45,
                                    min_following=77)

    session.set_dont_include(["friend1", "friend2", "friend3"])
    session.set_dont_like(["pizza", "#store"])

    # actions
    session.like_by_tags(["natgeo"], amount=10)

Execute it:

$ python quickstart.py
⁠Extensions

1. Session scheduling with Telegram⁠

⁠InstaPy Available Features

⁠Commenting
# default enabled=False, ~ every 4th image will be commented on

session.set_do_comment(enabled=True, percentage=25)
session.set_comments(['Awesome', 'Really Cool', 'I like your stuff'])

# you can also set comments for specific media types (Photo / Video)

session.set_comments(['Nice shot!'], media='Photo')
session.set_comments(['Great Video!'], media='Video')

# and you can add the username of the poster to the comment by using

session.set_comments(['Nice shot! @{}'], media='Photo')
⁠Following
# default enabled=False, follows ~ 10% of the users from the images, times=1
# (only follows a user once (if unfollowed again))

session.set_do_follow(enabled=True, percentage=10, times=2)
⁠Following by a list
⁠This will follow each account from a list of instagram nicknames
follow_by_list(followlist=['samantha3', 'larry_ok'], times=1, sleep_delay=600, interact=False)

only follows a user once (if unfollowed again) would be useful for the precise targeting
sleep_delay is used to define break time after some good following (averagely ~10 follows)
For example, if one needs to get followbacks from followers of a chosen account/group of accounts.

accs = ['therock','natgeo']
session.follow_by_list(accs, times=1, sleep_delay=600, interact=False)
  • You can also interact with the followed users by enabling interact=True which will use the configuration of set_user_interact setting:
session.set_user_interact(amount=4,
				 percentage=50,
                  randomize=True,
                   media='Photo')
session.follow_by_list(followlist=['samantha3', 'larry_ok'], times=2, sleep_delay=600, interact=True)
⁠Follow someone else's followers
# Follows the followers of each given user
# The usernames can be either a list or a string
# The amount is for each account, in this case 30 users will be followed
# If randomize is false it will pick in a top-down fashion

session.follow_user_followers(['friend1', 'friend2', 'friend3'], amount=10, randomize=False)

# default sleep_delay=600 (10min) for every 10 user following, in this case
# sleep for 60 seconds

session.follow_user_followers(['friend1', 'friend2', 'friend3'], amount=10, randomize=False, sleep_delay=60)

Note: simulation⁠ takes place while running this feature.

⁠Follow users that someone else is following
# Follows the people that a given users are following
# The usernames can be either a list or a string
# The amount is for each account, in this case 30 users will be followed
# If randomize is false it will pick in a top-down fashion

session.follow_user_following(['friend1', 'friend2', 'friend3'], amount=10, randomize=False)

# default sleep_delay=600 (10min) for every 10 user following, in this case
# sleep for 60 seconds

session.follow_user_following(['friend1', 'friend2', 'friend3'], amount=10, randomize=False, sleep_delay=60)

Note: simulation⁠ takes place while running this feature.

⁠Follow someone else's followers/following
# For 50% of the 30 newly followed, move to their profile
# and randomly choose 5 pictures to be liked.
# Take into account the other set options like the comment rate
# and the filtering for inappropriate words or users

session.set_user_interact(amount=5, randomize=True, percentage=50, media='Photo')
session.follow_user_followers(['friend1', 'friend2', 'friend3'], amount=10, randomize=False, interact=True)
⁠Follow by Tags
# Follow user based on hashtags (without liking the image)

session.follow_by_tags(['tag1', 'tag2'], amount=10)
⁠Follow the likers of photos of users
⁠This will follow the people those liked photos of given list of users
session.follow_likers (['user1' , 'user2'], photos_grab_amount = 2, follow_likers_per_photo = 3, randomize=True, sleep_delay=600, interact=False)

in this case 2 random photos from each given user will be analyzed and 3 people who liked them will be followed, so 6 follows in total
The usernames can be any list
The photos_grab_amount is how many photos will I grat from users profile and analyze who liked it
The follow_likers_per_photo is how many people to follow per each photo
randomize=False will take photos from newes, true will take random from first 12
sleep_delay is used to define break time after some good following (averagely ~10 follows)

  • You can also interact with the followed users by enabling interact=True which will use the configuration of set_user_interact setting:
session.set_user_interact(amount=2,
				 percentage=70,
                  randomize=True,
                   media='Photo')
session.follow_likers (['user1' , 'user2'], photos_grab_amount = 2, follow_likers_per_photo = 3, randomize=True, sleep_delay=600, interact=True)
⁠Follow the commenters of photos of users
⁠This will follow the people those commented on photos of given list of users
session.follow_commenters(['user1', 'user2', 'user3'], amount=100, daysold=365, max_pic = 100, sleep_delay=600, interact=False)

in this case (max 100 newest photos & maximum 365 days old) from each given user will be analyzed and 100 people who commented the most will be followed
The usernames can be any list
The amount is how many people to follow
The daysold will only take commenters from photos no older than daysold days
The max_pic will limit number of photos to analyze
sleep_delay is used to define break time after some good following (averagely ~10 follows)

  • You can also interact with the followed users by enabling interact=True which will use the configuration of set_user_interact setting:
session.set_user_interact(amount=3,
				 percentage=32,
                  randomize=True,
                   media='Video')
session.follow_commenters(['user1', 'user2', 'user3'], amount=100, daysold=365, max_pic = 100, sleep_delay=600, interact=True)
⁠Interact with specific users
# Interact with specific users
# set_do_like, set_do_comment, set_do_follow are applicable

session.set_do_follow(enabled=False, percentage=50)
session.set_comments(["Cool", "Super!"])
session.set_do_comment(enabled=True, percentage=80)
session.set_do_like(True, percentage=70)
session.interact_by_users(['user1', 'user2', 'user3'], amount=5, randomize=True, media='Photo')
⁠Interact with specific users' tagged posts
# Interact with specific users' tagged posts
# set_do_like, set_do_comment, set_do_follow are applicable

session.set_do_follow(enabled=False, percentage=50)
session.set_comments(["Cool", "Super!"])
session.set_do_comment(enabled=True, percentage=80)
session.set_do_like(True, percentage=70)
session.interact_by_users_tagged_posts(['user1', 'user2', 'user3'], amount=5, randomize=True, media='Photo')
⁠Interact with users that someone else is following
# Interact with the people that a given user is following
# set_do_comment, set_do_follow and set_do_like are applicable

session.set_user_interact(amount=5, randomize=True, percentage=50, media='Photo')
session.set_do_follow(enabled=False, percentage=70)
session.set_do_like(enabled=False, percentage=70)
session.set_comments(["Cool", "Super!"])
session.set_do_comment(enabled=True, percentage=80)
session.interact_user_following(['natgeo'], amount=10, randomize=True)

Note: simulation⁠ takes place while running this feature.

⁠Interact with someone else's followers
# Interact with the people that a given user is followed by
# set_do_comment, set_do_follow and set_do_like are applicable

session.set_user_interact(amount=5, randomize=True, percentage=50, media='Photo')
session.set_do_follow(enabled=False, percentage=70)
session.set_do_like(enabled=False, percentage=70)
session.set_comments(["Cool", "Super!"])
session.set_do_comment(enabled=True, percentage=80)
session.interact_user_followers(['natgeo'], amount=10, randomize=True)

Note: simulation⁠ takes place while running this feature.

⁠Interact on posts at given URLs
⁠Like, comment, follow on the post in the links provided, also can interact the owner of the post
session.interact_by_URL(urls=["some/URL/1", "some/URL/2" "other/URL"], randomize=True, interact=True)

To use, define all of the interaction settings and start the feature right away!

#define interaction settings
session.set_do_like(enabled=True, percentage=94)
session.set_do_comment(enabled=True, percentage=24)
session.set_comments(["Masterful shot", "Chilling!", "Unbelievably great..."])
session.set_do_follow(enabled=True, percentage=44)
session.set_user_interact(amount=6, randomize=True, percentage=72, media='Photo')

#start the feature
session.interact_by_URL(urls=["Fv0J4AJ3Y7r/?taken-at=628416252", "Vb0D4bJgY7r" "Dj0J4VJgY7r"], randomize=True, interact=True)
⁠Parameters:

urls:
Contains the URLs of the posts to be interacted.

  • You can provide URLs in these formats:
    full: "https://www.IG.com/p/Aj0J4bJDY7r/?taken-at=128316221"
    just post link: "https://www.IG.com/p/Aj0J4bJDY7r/"
    just post handle: "Aj0J4bJDY7r/?taken-at=128316221"
    just post ID: "Aj0J4bJDY7r"

randomize:
Shuffles the order of the URLs in the given list before starts to interact.

interact:
Use it if you like to also interact the post owner after doing interactions on the post itself.

⁠Interact by Comments
⁠Like comments on posts, reply to them and then interact by the users whose comment was liked on the post
session.interact_by_comments(usernames=["somebody", "other buddy"],
                             posts_amount=10,
                             comments_per_post=5,
                             reply=True,
                             interact=True,
                             randomize=True,
                             media="Photo")
⁠Parameters

usernames : A list containing the usernames of users on WHOSE posts' comments will be interacted;

posts_amount : Number of the posts to get from each user for interacting by comments;

comments_per_post : Choose how many comments to interact (like and then reply) on each post;

reply : Choose if it should reply to comments;

interact : Use if you also like to interact the commenters after finishing liking (and then replying to) comments on the post;

randomize : Shuffles the order of the posts from users' feed and comments in the given post;

media : Choose the type of media to be interacted - "Photo" for photos, "Video" for videos, None for any media;

⁠Usage

To use, set replying and interaction configuration(s)

session.set_do_reply_to_comments(enabled=True, percentage=14)
session.set_comment_replies(replies=[u"😎😎😎", u"😁😁😁😁😁😁😁πŸ’ͺ🏼", u"πŸ˜‹πŸŽ‰", "πŸ˜€πŸ¬", u"πŸ˜‚πŸ˜‚πŸ˜‚πŸ‘ˆπŸΌπŸ‘πŸΌπŸ‘πŸΌ", u"πŸ™‚πŸ™‹πŸΌβ€β™‚οΈπŸš€πŸŽŠπŸŽŠπŸŽŠ", u"😁😁😁", u"πŸ˜‚",  u"πŸŽ‰",  u"😎", u"πŸ€“πŸ€“πŸ€“πŸ€“πŸ€“", u"πŸ‘πŸΌπŸ˜‰"],
                            media="Photo")

session.set_user_interact(amount=2, percentage=70, randomize=False, media="Photo")
# also configure [at least] liking to be used while interacting with the commenters ...
session.set_do_like(enabled=True, percentage=94)

# start the feature
session.interact_by_comments(usernames=["somebody", "other.buddy"], posts_amount=10, comments_per_post=5, reply=True, interact=True, randomize=True, media="Photo")

Note: To be able to reply to comments, you have to turn on text analytics- Yandex⁠ & MeaningCloud⁠.
So that they will analyze the content of comments and if it is appropriate, will send a reply to the comment.
To configure those text analytics, see the usage in their sections.

There are 3 COMBINATIONS available to use regarding text analysis:
a-) ONLY Sentiment Analysis;
MeaningCloud must be turned on and Yandex must be enabled with a valid API key,

session.set_use_meaningcloud(enabled=True, license_key='', polarity="P")
session.set_use_yandex(enabled=True, API_key='')

b-) ONLY Language Match; Yandex must be turned on,

session.set_use_yandex(enabled=True, API_key='', match_language=False, language_code="en")

c-) BOTH Sentiment Analysis and Language Match; MeaningCloud and Yandex must be turned on,

session.set_use_meaningcloud(enabled=True, license_key='', polarity="P")
session.set_use_yandex(enabled=True, API_key='', match_language=True, language_code="en")

If you have followed any of those 3 text analysis combinations:
It will first analyze comments' content and if it is appropriate, then it will first like, then will reply to it.
All those inappropriate comments will neither be liked, nor replied to.

If you have not followed any of those 3 text analysis combinations OR misconfigured them:
Comments' content will not be able to be analyzed and that's why no any comments will be replied.
Yet, it will like all of the comments that are available.

In conclusion, the whole block SHOULD look like this,

session.set_use_meaningcloud(enabled=True, license_

Tag summary

Content type

Image

Digest

Size

182.9 MB

Last updated

almost 8 years ago

docker pull funkypenguin/instapy