使用 Python 将图像上传到 Instagram

Ale*_*ena 8 python python-2.7 instagram instagram-api

我正在尝试做一个简单的 Instagram python 机器人,以便在我的 Instagram 个人资料中上传图像。我已经尝试过最常用的库(InstagramAPI、instapy、insta-cly)。在我搜索的过程中,我发现 Instagram 改变了一些东西,使这些库变得毫无用处。

有我可以使用的图书馆吗?我知道我可以使用 Selenium 来让它运行,但我想知道是否有任何捷径。

调戏你!

Sai*_*ine 5

试试这个库:instabot https://pypi.org/project/instabot/

上传图片的代码示例:

from instabot import Bot

bot = Bot()
bot.login(username="instagram_username", password="your_password")

file = open('path_to_your_image', 'r')
bot.upload_photo(file, caption="your post caption")
Run Code Online (Sandbox Code Playgroud)

  • 不知道是否是包更新,但 bot.upload_photo 应该接收媒体项的路径,而不是文件实例 (2认同)