自动收集Twitter流数据

twistream的Python项目详细描述


Twistream:Twitter流API数据收集

CircleCIPyPI version

Twistream帮助您从Twitter流API自动收集和存储数据。在

安装

最新稳定版本:

pip install twistream

来源:

^{pr2}$

设置

Twitter凭据

您需要您的twitter凭据才能使用twitter API。为此, 创建应用程序here。创建后,保存要配置的凭据 扭流

创建配置文件

您可以使用命令twistream init来帮助您创建格式正确的配置文件 为了你的收藏。在

创建后,您将有一个文件,该文件将如下所示:

~> cat ~/.twistream/twistream.yml      

twitter:                  
  consumer_key: your_consumer_key                   
  consumer_secret: your_consumer_secret             
  access_token_key: your_access_token_key             
  access_token_secret: your_access_token_secret       


backend: backend_name                  

backend_params:
    username: db_username
    password: db_password

使用

记住,--help始终是一个可用的选项

一旦创建了配置文件,就开始收集tweets!在

twistream collect --tracks tracks,to,follow config.yaml

请参阅twitter documentation以了解哪些轨迹,简而言之:

A comma-separated list of phrases which will be used to determine what Tweets will be delivered on the stream. A phrase may be one or more terms separated by spaces, and a phrase will match if all of the terms in the phrase are present in the Tweet, regardless of order and ignoring case. By this model, you can think of commas as logical ORs, while spaces are equivalent to logical ANDs (e.g. ‘the twitter’ is the AND twitter, and ‘the,twitter’ is the OR twitter).

如果您想要跟随hashtags,请不要忘记包含#字符。在

支持的后端

从版本0.1.3开始,twistream支持两个后端。关系数据库(SQLite)和非sql数据库(MongoDB)。在

请注意,SQLite后端只保存几个tweet字段,而MongoDB后端将保存整个blob。 它是信息和存储空间之间的权衡。在

后端参数格式

SQLite
backend: sqlite

backend_params:
    db_path: /path/to/your/db
MongoDB
backend: mongodb

backend_params:
    db_string: database_connection_string

(请参阅数据库连接字符串文档)

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何使用println按单位打印同一列中的数字列表?   java MigLayout表单类型结构问题   java无法让库Maven依赖项出现   java查找状态为a、b或c且数组大于0的MongoDB记录   方法内部的java用户输入和对象创建   Java中需要使用特殊字符(键盘中未给出)   java为什么实例变量不调用方法不重写升级?   未在方法级别调用java侦听器   java GUI/应用程序通信   使用@Mock注释的java对象应该设置为详细值吗?   java不确定如何在主线程中引用stringArray   使用selenium和java并行检查页面上的断开链接   java Glassfish容器安全认证如何添加盐(j_安全检查)   如何使用JavaPOI将列的数据从输入excel写入输出excel   java与我们在getMetaData方法中不使用的数组相混淆