python - 为已在 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')
解决方案
推荐阅读
- web-services - .NET 的简单 HTTP 服务器库
- javascript - 给定 url 字符串、参数、响应代码和 JSON 中的响应,以最大的灵活性伪造后端的方法
- postgresql - Postgresql CHECK IN 列表约束的自定义错误消息
- python - 在 Django 中为 BooleanField 使用不同的数据库值
- java - 带有 RoutingConnectionFactory 的 Spring RabbitListener
- elasticsearch - 从脚本 ElasticSearch/Painless 中的 aggs 获取结果
- python - 网络 x 图和弗洛伊德 Warshall
- java - java java.util.ConcurrentModificationException,同时将属性添加到 apache jena
- javascript - 返回全局数组元素
- jquery - 如何单击动态创建的元素以在 jQuery 中切换回撤?