tweepy Streaming API integration with Django

后端 未结 1 1363
情歌与酒
情歌与酒 2021-02-02 05:03

I am trying to create a Django webapp that utilizes the Twitter Streaming API via the tweepy.Stream() function. I am having a difficult time conceptualizing the proper implemen

1条回答
  •  星月不相逢
    2021-02-02 05:22

    There are various ways to do this, but using a messaging lib (celery) will probably be the easiest.

    1) Keep a python process running tweepy. Once an interesting message is found, create a new celery task

    2) Inside this carrot task persist the data to the database (the counter, the tweets, whatever). This task can well run django code (e.g the ORM).

    3) Have a regular django app displaying the results your task has persisted.

    As a precaution, it's probably a good ideal to run the tweepy process under supervision (supervisord might suit your needs). If anything goes wrong with it, it can be restarted automatically.

    0 讨论(0)
提交回复
热议问题