Instapy: Feature: run for infinity.

Created on 7 Nov 2017  路  11Comments  路  Source: timgrossmann/InstaPy

I implemented a feature for MAX PER HOUR & MAX PER DAY.
I would like to know what is the suggested solution to rerun the script each time it ended/crashs.
I am currently using while(true) and try except inside it.
but it not working the best ;~(

Any suggestions?

Thanks.

help wanted question

Most helpful comment

@sionking Can you create a branch and share the code change to us, including the Max Per hour and Max Per day, I think that will help quite few of us in the community. thank you.

All 11 comments

session = InstaPy(username=insta_username, password=insta_password)

while (True):
    try:
        session.login()
        session.set_upper_follower_count(limit=1500)

        session.set_do_comment(True, percentage=5)
        session.set_do_follow(True, percentage=80, times=1)

        session.set_comments(['beautiful', u'\u2665''])
        session.like_by_tags(taglist, amount=500)
        session.like_by_feed(amount=80)

        session.browser.close()
        session.set_selenium_local_session()
    except KeyboardInterrupt:
        session.end()
        quit()
    except:
        print('error or ctrl-c')
        session.browser.close()
        session.set_selenium_local_session()

I think this works for me, please take a look and check.

The idea is to let the script run without caring for crashes, it will run forever but counting the MAX per day we have. Much easier maintaine.

@sionking Can you create a branch and share the code change to us, including the Max Per hour and Max Per day, I think that will help quite few of us in the community. thank you.

@sionking Let us know if you get ban

I won't get banned since I am setting MAX per HOUR and MAX per day...
BTW I don't know hot to do PR .. I will figure it out soon :)

@sionking commit > push to your github fork > new pull request (on your github fork)

Is this working fine? How do I add it to the code?

@sionking did something

while True:
    try:
        start = datetime.datetime.now()
        # set up all the settings
        session.set_upper_follower_count(limit=2500)
        session.set_do_follow(enabled=True, percentage=3, times=2)
        session.follow_user_followers(['user1', 'user2'],
                                      amount=10, random=True, sleep_delay=600)
        session.unfollow_users(amount=25, onlyInstapyFollowed=True,
                               onlyInstapyMethod='FIFO', sleep_delay=600)
        session.set_unfollow_active_users(enabled=False, posts=5)
        session.set_dont_like(['pizza', 'girl', 'nsfw'])
        # do the actual liking
        session.like_by_tags(['tag'], amount=13)
        while True:
            stop = datetime.datetime.now()
            elapsed = stop - start
            if elapsed < datetime.timedelta(hours=1):
                sleep(2)
            else:
                break

Note testing it right now

Is here any update?

I want to run this endless with limit per hour and per day or something... any Updates to this?

@Marow I see there is multiple suggestion from multiple people, have you ever tried those ? if not, give a try and provide any feedback.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rahulkapoor90 picture rahulkapoor90  路  3Comments

ingorichter picture ingorichter  路  3Comments

ediooo picture ediooo  路  3Comments

Naramsim picture Naramsim  路  3Comments

tibor picture tibor  路  3Comments