from instabot import Bot
import os
import shutil
def clean_up():
dir = "config"
remove_me = "imgs\img.jpg.REMOVE_ME"
# checking whether config folder exists or not
if os.path.exists(dir):
try:
# removing it because in 2021 it makes problems with new uploads
shutil.rmtree(dir)
except OSError as e:
print("Error: %s - %s." % (e.filename, e.strerror))
if os.path.exists(remove_me):
src = os.path.realpath("imgs\img.jpg")
os.rename(remove_me, src)
def upload_post():
bot = Bot()
bot.login(username="your_username", password="your_password")
bot.upload_photo("imgs/img.jpg", caption="Caption for the post")
if __name__ == '__main__':
clean_up()
upload_post()
尝试此库:instabothttps://pypi.org/project/instabot/
上载图像的代码示例:
Instabot python库允许您上传图像、故事、视频、发表评论等,但还有一些问题在其他答案中无法解决,因此我编写了这段代码,为您解决所有这些问题
相关问题 更多 >
编程相关推荐