我正在寻找一种工具,让我可以从 python post 到 Instagram

I am looking for a tool that allows me to post to Instagram from python

我正在寻找一种工具,可以让我从 python 到 Instagram post。

我想使用像 Heroku 或 GCP 云调度程序这样的调度程序来自动化这个过程,所以我们认为使用 GUI 的 selenium 之类的东西不太合适。 (不过,用硒可能 运行 它。)

我已经试过instapy-cli和instabot了,但是现在好像不可用了。

https://github.com/b3nab/instapy-cli

https://instagrambot.github.io/

你可以试试the official Instagram API for which you are going to have to set up a business account.

您可以尝试使用来自 Automating Instagram Posts with Python and Instagram Graph API 的代码。

import requests
import config
import json
def postInstagramQuote():
#Post the Image
    image_location_1 = 'http:path-to-your-image.com/img/image-name.jpg'
    post_url = 'https://graph.facebook.com/v10.0/{}/media'.format(config.ig_user_id)
payload = {
    'image_url': image_location_1,
    'caption': 'Get jobs online on https://careers-portal.co.za #career #hiring #jobs #job #jobssouthafrica #hiringnow,
    'access_token': config.user_access_token
    }
    r = requests.post(post_url, data=payload)
    print(r.text)
result = json.loads(r.text)
    if 'id' in result:
        creation_id = result['id']
second_url = 'https://graph.facebook.com/v10.0/{}/media_publish'.format(config.ig_user_id)
        second_payload = {
        'creation_id': creation_id,
        'access_token': config.user_access_token
        }
        r = requests.post(second_url, data=second_payload)
        print('--------Just posted to instagram--------')
        print(r.text)
    else:
        print('HOUSTON we have a problem')
postInstagramQuote()

提醒:您只能从 Instagram 企业帐户 post 访问您的个人 Instagram 帐户。