从URL更改Twitter横幅广告

问题描述 投票:0回答:1

如何使用tweepy库通过使用来自URL的图像来更改Twitter横幅:https://github.com/tweepy/tweepy/blob/v2.3.0/tweepy/api.py#L392

到目前为止,我得到了它,它返回:

def banner(self):
    url = 'https://blog.snappa.com/wp-content/uploads/2019/01/Twitter-Header-Size.png'
    file = requests.get(url)
    self.api.update_profile_banner(filename=file.content)

ValueError: stat: embedded null character in path

似乎文件名要求下载图像。是否要处理此问题而不下载图像然后将其删除?

python tweepy
1个回答
0
投票

查看库的代码,您可以执行所需的操作。

def update_profile_banner(self, filename, *args, **kargs):
    f = kargs.pop('file', None)

所以您需要做的是提供文件名和文件kwarg:

filename = url.split('/')[-1]
self.api.update_profile_banner(filename, file=file.content)
© www.soinside.com 2019 - 2024. All rights reserved.