You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Python InstaBot报Out of Follows for today及TypeError错误修复咨询

问题修复方案

1 直接报错的根因修复

你遇到的TypeError: '>' not supported between instances of 'int' and 'str'报错,是因为input()函数默认返回字符串类型,你直接用int类型的计数器i和字符串类型的FollowCount比较,触发了类型不兼容错误。
修改方式:把输入的FollowCount转成int类型,代码修改为:

FollowCount = int(input("How many People do you want to follow"))

可额外增加输入校验逻辑,捕获用户输入非数字的异常,避免程序意外崩溃

2 关注终止逻辑错误修复

你当前的终止判断if i > FollowCount: break写在了关注失败的else分支里,只有关注失败的时候才会判断是否达到关注数量,逻辑完全错误。正确逻辑应该是每次成功关注后判断是否达到上限,达到就直接终止循环:
修改后的关注循环代码:

i = 0
for user in followers[105:]:
    # 先判断是否已经达到目标数量,达到直接退出
    if i >= FollowCount:
        break
    username = bot.get_username_from_user_id(user)
    print("Attempting to follow:", username)
    if bot.follow(username):
        i += 1
        print("Followed! -", username)
    else:
        print("Not Followed ! - ", username)

3 其他潜在问题修复

  • 第二段取关循环里用到了following变量,但是代码中没有提前定义该变量,运行到此处会直接报NameError,需要在取关循环前提前获取你自己账号的关注列表:
following = bot.get_user_following(bot.user_id)
  • 日志中的Out of follows for today是Instagram官方限流提示,说明你的账号当天的关注操作已经触达平台上限,不属于代码错误。建议你降低单日操作总量、拉长follow_delay的间隔时间,避免账号被判定为营销号封禁。

内容的提问来源于stack exchange,提问作者KiddCm

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.02 23:06:03