【问题标题】:sending post using instagrapi使用 instagrapi 发送帖子
【发布时间】:2021-10-15 03:35:52
【问题描述】:

您好,我正在尝试使用 instagrapi 模块将帖子发送到 Instagram 我正在使用photo_upload 来做到这一点,但这不起作用 这是我的代码:

from instagrapi import Client

print("im gonna log in")
cl = Client()
cl.login("UserName", "Password")

cl.photo_upload("picture.png", "hello this is a test from instagrapi")

但我收到此错误:

Traceback (most recent call last):   File "E:\HadiH2o\Documents\_MyProjects\Python\Test\Test.py", line 10, in <module>   File "C:\Users\HadiH2o\AppData\Local\Programs\Python\Python39\lib\site-packages\instagrapi\mixins\photo.py", line 205, in photo_upload
    upload_id, width, height = self.photo_rupload(path, upload_id)   File "C:\Users\HadiH2o\AppData\Local\Programs\Python\Python39\lib\site-packages\instagrapi\mixins\photo.py", line 170, in photo_rupload
    raise PhotoNotUpload(response.text, response=response, **last_json) instagrapi.exceptions.PhotoNotUpload: {"debug_info":{"retriable":false,"type":"ProcessingFailedError","message":"Request processing failed"}}

请帮忙!

【问题讨论】:

    标签: python instagram photo-upload


    【解决方案1】:

    我找到了问题的答案 要将帖子发送到 Instagram,照片格式必须为 JPG,并且照片尺寸必须小于 1080 x 1080。

    这是代码:

    from pathlib import Path
    from PIL import Image
    from instagrapi import Client
    
    image = Image.open("picture.jpg")
    image = image.convert("RGB")
    new_image = image.resize((1080, 1080))
    new_image.save("new_picture.jpg")
    
    
    cl = Client()
    cl.login("UserName", "Password")
    
    phot_path = "new_picture.jpg"
    phot_path  = Path(phot_path)
    
    cl.photo_upload(phot_path , "hello this is a test from instagrapi")
    

    【讨论】:

      猜你喜欢
      • 2022-12-15
      • 2011-09-06
      • 2011-06-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-10
      相关资源
      最近更新 更多