twitter.py 文件源码

python
阅读 67 收藏 0 点赞 0 评论 0

项目:QProb 作者: quant-trade 项目源码 文件源码
def post_tweet(data):
    try:
        post = Post.objects.get(title=data['title'])

        tags = await get_tags(post=post)
        media = await get_media(post=post)
        sentiment = post.sentiment or "N/A"

        if not (tags is None):
            status = "{0} [{1}]: {2}{3}/ {4}".format(post.title[:80], sentiment, settings.DOMAIN, post.slug, tags)
        else:
            status = "{0} [{1}]: {2}{3}/".format(post.title[:80], sentiment, settings.DOMAIN, post.slug)

        if not (media is None):
            api.PostUpdate(status=status, media=media)
        else:
            api.PostUpdate(status=status, media=None)

        print(colored.green("Sent tweet {}.".format(status)))

    except Exception as e:
        print(colored.red("At Twitter post: {0}".format(e)))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号