简体   繁体   English

Python:在 heroku 上运行 Instapy

[英]Python: Running Instapy on heroku

I am trying to create a instagram bot on heroku.我正在尝试在 heroku 上创建一个 instagram 机器人。 I am new to this, I don't know where the tracebacks are going.我是新手,我不知道回溯的去向。 heroku logs --tail Isn't much of a help. heroku logs --tail没有多大帮助。

What I did so far:到目前为止我做了什么:

On the terminal:在终端上:

heroku buildpacks:add heroku/chromedriver master

heroku buildpacks:add heroku/google-chrome master

Procfile:简介:

web: gunicorn routes:app

routes.py:路线.py:

from instapy import InstaPy
from instapy.util import smart_run
from flask import Flask


app = Flask(__name__)
# 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=True,
                nogui=True)

@app.route('/')
def index():
    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)

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

    return 'Done'

I think you want to change your Procfile to this:我认为您想将 Procfile 更改为:

web: gunicorn app:app --log-file=-

for logging.用于记录。 Mine says app:app because my py file is called app, yours should say:我的说 app:app 因为我的 py 文件被称为 app,你的应该说:

web: gunicorn routes:app --log-file=-

Also, I prefer to use the command:另外,我更喜欢使用以下命令:

heroku logs -t -a <insert app name here>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM