Instapy: Setup a Schedule // Droplet with Unbutu

Created on 21 Oct 2017  路  6Comments  路  Source: timgrossmann/InstaPy

Hi.

I'm wondering how to setup a scheduler.
I tried the Automate with Schedule

Schedule is an in-process scheduler for periodic jobs that uses the builder pattern for configuration. Schedule lets you run Python functions periodically at pre-determined intervals using a simple, human-friendly syntax.

pip install schedule
from instapy import InstaPy
import schedule
import time

def job():
    try:
        session = InstaPy(selenium_local_session=False) # Assuming running in Compose
        session.set_selenium_remote_session(selenium_url='http://selenium:4444/wd/hub')
        session.login()
        session.set_do_comment(enabled=True, percentage=20)
        session.set_comments(['Well done!'])
        session.set_do_follow(enabled=True, percentage=5, times=2)
        session.like_by_tags(['love'], amount=100, media='Photo')
        session.end()
    except:
        import traceback
        print(traceback.format_exc())

schedule.every().day.at("6:35").do(job)
schedule.every().day.at("16:22").do(job)

while True:
    schedule.run_pending()
    time.sleep(1)

but they don't really make sense to me.

I also looked into https://github.com/Tkd-Alex/Telegram-InstaPy-Scheduling but that's not making much sense to me on how to get a token. Could anyone provide me with some clues?

@tkd-alex ?

help wanted question

Most helpful comment

@brookton I think this is way easier to work with and actually close to as customizable as schedule

E.g you could simply do

0 */4 * * * cd /InstaPy && python3.5 quickstart.py

To run it every 4 hours

All 6 comments

I'm sorry it's a pretty basic question, but where do I put this?

from instapy import InstaPy
import schedule
import time

def job():
try:
session = InstaPy(selenium_local_session=False) # Assuming running in Compose
session.set_selenium_remote_session(selenium_url='http://selenium:4444/wd/hub')
session.login()
session.set_do_comment(enabled=True, percentage=20)
session.set_comments(['Well done!'])
session.set_do_follow(enabled=True, percentage=5, times=2)
session.like_by_tags(['love'], amount=100, media='Photo')
session.end()
except:
import traceback
print(traceback.format_exc())

schedule.every().day.at("6:35").do(job)
schedule.every().day.at("16:22").do(job)

while True:
schedule.run_pending()
time.sleep(1)

when I try to run the first line as a command and I get this error

The program 'import' can be found in the following packages:

  • imagemagick
  • graphicsmagick-imagemagick-compat
    Try: apt install

Am I meant to install it in the instapy.py file?
Just kind of confused and not finding many support documents about it.
Sorry I'm such a noob! Any resources would be awesome

Much appreciated.

Anyone? 馃様

@brookton Hey, I would simply use a cronjob to do that.

you can setup a cronjob with crontab -e. This will open up an editor window where you have to specify dates.

E.g. you can do that

35 6 * * * cd /InstaPy && python3.5 quickstart.py
22 16 * * * cd /InstaPy && python3.5 quickstart.py

@brookton I think this is way easier to work with and actually close to as customizable as schedule

E.g you could simply do

0 */4 * * * cd /InstaPy && python3.5 quickstart.py

To run it every 4 hours

Thank you so much Tim! It does indeed make sense now I was making it a bit too complicated.

Appreciated!

@brookton Do you think we can close this issue? 馃槈

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Spyd3r0us picture Spyd3r0us  路  3Comments

wyvers picture wyvers  路  3Comments

tibor picture tibor  路  3Comments

harrypython picture harrypython  路  3Comments

ediooo picture ediooo  路  3Comments