首页 > 解决方案 > 为已在 InstaPy 库中分配的类似创建异常

问题描述

我有下面的算法,通过 URL 对 instagram 照片执行喜欢和评论,我的目标是在 5 分钟内在 AWS 机器上运行此脚本,每天将生成 288 条评论。然而,每当他意识到他已经在照片中执行了 LIKE 时,他就会返回"LIKED 0 images | ALREADY LIKED: 1"并中止该过程。我想在 LIKE 已经存在时创建一个交易,只需执行评论,可以吗?如果是,您可以帮助我提供相关示例或解决方案,谢谢!

from instapy import InstaPy
from instapy import smart_run

def connect(insta_username,insta_password):

    try:

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

        return session

    except Exception as e:
        print("[FAILED] Caused by: {}".format(e))

def action(url,insta_username,insta_password):

    session = connect(insta_username,insta_password)

    try:

        with smart_run(session):

            # Always follow and like before, the algorithm understands how it has already been executed when used in place of the like function
            # Define interaction settings
            session.set_do_comment(enabled=True, percentage=100)
            session.set_comments(["@user-id"])
            session.set_user_interact(amount=1, randomize=False, percentage=100, media='Photo')

            # Start the feature
            session.interact_by_URL(urls=url, randomize=False, interact=True)
            session.end()

    except Exception as e:
        print("[FAILED] Caused by: {}".format(e))

if __name__ == "__main__":
    pics = ["https://www.instagram.com/p/id-here"]
    for url in pics:
        action(url,'username','password')

标签: pythoninstagramexceptinstapy

解决方案


推荐阅读