How to use the instapy.util.smart_run function in instapy

To help you get started, we’ve selected a few instapy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github breuerfelix / instapy-gui / services / instapy / bot.py View on Github external
# set assets folder as a workspace
ASSETS = os.path.dirname(os.path.abspath(__file__)) + '/assets'
set_workspace(ASSETS)

# get an InstaPy session!
session = InstaPy(**instapy_args)

# function that will be executed before sig kill, to the browser window closes
def exit_browser(*args):
    session.browser.quit()


if platform.system() != 'Windows':
    signal.signal(signal.SIGUSR1, exit_browser)

with smart_run(session):
    for job in jobs:
        arguments = dict()
        for param in job['params']:
            arguments[param['name']] = param['value']

        getattr(session, job['functionName'])(**arguments)
github breuerfelix / instapy-gui / services / start_bot.py View on Github external
# convert to list
            param['value'] = param['value'].split(';')



    # login credentials
    insta_username = user['username']
    insta_password = user['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):
        for job in jobs:
            arguments = dict()
            for param in job['params']:
                arguments[param['name']] = param['value']

            getattr(session, job['functionName'])(**arguments)
github Instagram-Tools / bot / quickstart_templates / Playing around with Quota Supervisor.py View on Github external
- Just started playing around with Quota Supervisor, so I'm still tweaking these settings
"""


import random
from instapy import InstaPy
from instapy.util import smart_run



# get a session!
session = InstaPy(username='', password='')


# let's go! :>
with smart_run(session):
    # general settings
    session.set_quota_supervisor(enabled=True,sleep_after=["server_calls_h"], sleepyhead=True, stochastic_flow=True, notify_me=True,
                                 peak_likes=(57, 585), peak_follows=(48, None), peak_unfollows=(35, 402), peak_server_calls=(500, None))
    session.set_relationship_bounds(enabled=True,
                                     potency_ratio=-1.3,
                                     delimit_by_numbers=True,
                                      max_followers=10000,
                                      max_following=15000,
                                      min_followers=75,
                                      min_following=75)
    session.set_do_comment(False, percentage=10)
    session.set_comments(['aMEIzing!', 'So much fun!!', 'Nicey!'])
    session.set_use_clarifai(enabled=True, api_key='')
    session.clarifai_check_img_for(['nsfw', 'gay', 'hijab', 'niqab', 'religion', 'shirtless', 'fitness', 'yamaka', 'rightwing'], comment=False)
    session.set_dont_like(['dick', 'squirt', 'gay', 'homo', '#fit', '#fitfam', '#fittips', '#abs', '#kids', '#children', '#child', '[nazi',
                        'jew', 'judaism', '[muslim', '[islam', 'bangladesh','[hijab', '[niqab','[farright', '[rightwing', '#conservative', 'death', 'racist'])
github Instagram-Tools / bot / quickstart_templates / Follow unfollow & send Telegram msg.py View on Github external
def follow():
    # Send notification to my Telegram
    requests.get(
        "https://api.telegram.org/******&text='InstaPy Follower Started @ {}'"
        .format(datetime.now().strftime("%H:%M:%S")))

    # get a session!
    session = get_session()

    # let's go!
    with smart_run(session):
        counter = 0

        while counter < 5:
            counter += 1

            try:
                # settings
                session.set_relationship_bounds(enabled=True, potency_ratio=1.21)

                # activity
                session.follow_by_tags(['tehran','تهران'], amount=5)
                session.follow_user_followers(['donya', 'arat.gym'], amount=5, randomize=False)
                session.follow_by_tags(['کادو','سالن','فروشگاه','زنانه','فشن','میکاپ','پوست','زیبا'], amount=10)
                session.follow_by_tags(['لاغری','خرید_آنلاین','کافی_شاپ','گل'], amount=5)
                session.unfollow_users(amount=25, allFollowing=True, style="LIFO", unfollow_after=3*60*60, sleep_delay=450)
github Instagram-Tools / bot / quickstart_templates / friends_last_post_likes_and_interact_with_user_based_on_hashtahs.py View on Github external
"""
Generating 5 comments built with random selection and amount of emojis from characters
"""
comments = []
characters = [u'😮', u'🌱', u'🍕', u'🚀', u'💬', u'💅', u'🦑', u'🌻', u'⚡️', u'🌈', u'🎉', u'😻']
for comment in range(5):
  comment = ''.join(random.sample(characters, random.randint(3,6)))
  comments.append(comment)

"""
Like last two posts from friendlists
"""
if data['friends_interaction']:
  friends = InstaPy(username=insta_username, password=insta_password, selenium_local_session=False, disable_image_load=True, multi_logs=False)
  friends.set_selenium_remote_session(selenium_url='http://selenium:4444/wd/hub')
  with smart_run(friends):
    print(u'💞 Showing friends some love 💖')
    friends.set_relationship_bounds(enabled=False)
    friends.set_skip_users(skip_private=False)
    friends.set_do_like(True, percentage=100)
    friends.interact_by_users(friendlist, amount=2, randomize=False)

"""
Collecting followers
"""
bot = InstaPy(username=insta_username, password=insta_password, selenium_local_session=False, disable_image_load=True, multi_logs=False)
bot.set_selenium_remote_session(selenium_url='http://selenium:4444/wd/hub')
with smart_run(bot):
  """
  Setting quota supervisor
  """
  bot.set_quota_supervisor(enabled=True, sleep_after=["server_calls_h"], sleepyhead=True, stochastic_flow=True, notify_me=True,
github Instagram-Tools / bot / quickstart_templates / Super simple settings for crontab.py View on Github external
What does this quickstart script aim to do?
- I am using simple settings for my personal account with a crontab each 3H, it's been working since 5 months with no problem.
"""


from instapy import InstaPy
from instapy.util import smart_run



# get a session!
session = InstaPy(username='', password='')


# let's go! :>
with smart_run(session):
    # settings
    session.set_relationship_bounds(enabled=False,
                                     potency_ratio=-1.21,
                                     delimit_by_numbers=True,
                                      max_followers=4590,
                                      max_following=5555,
                                      min_followers=45,
                                      min_following=77)
    session.set_do_comment(True, percentage=50)
    session.set_comments(['aMazing!', 'So cool!!', 'Nice!', 'wow looks nice!', 'this is awesome!'])

    # activity
    session.like_by_tags(['xxx', 'xxx', 'xxx', 'xxx', 'xxx', 'xxx', 'xxx', 'xxx', 'xxx', 'xxx', 'xxx', 'xxx', 'xxx'], amount=8, skip_top_posts=True)
github Instagram-Tools / bot / quickstart_templates / Like by tag interact unfollow.py View on Github external
like_tag_list = ['vegan','veganfoodshare', 'veganfood', 'whatveganseat', 'veganfoodie', 'veganism', 'govegan', 'veganism', 'vegansofig', 'veganfoodshare', 'veganfit', 'veggies']

# prevent posts that contain some plantbased meat from being skipped
ignore_list = ['vegan', 'veggie', 'plantbased']

accounts = ['accounts with similar content']



# get a session!
session = InstaPy(username=insta_username,
                      password=insta_password,
                      headless_browser=True)


with smart_run(session):
    # settings
    session.set_relationship_bounds(enabled=True,
				   max_followers=15000)

    session.set_dont_include(friends)
    session.set_dont_like(dont_likes)
    session.set_ignore_if_contains(ignore_list)

    session.set_user_interact(amount=2, randomize=True, percentage=60)
    session.set_do_follow(enabled=True, percentage=40)
    session.set_do_like(enabled=True, percentage=80)

    # activity
    session.like_by_tags(random.sample(like_tag_list, 3), amount=random.randint(50, 100), interact=True)

    session.unfollow_users(amount=random.randint(75,150), InstapyFollowed=(True, "all"), style="FIFO", unfollow_after=90*60*60, sleep_delay=501)