CODE:

  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3.  
  4. '''
  5. Created on 2014-7-18
  6. @author: guaguastd
  7. @name: collect_time_series.py
  8. '''
  9.  
  10. if __name__ == '__main__':
  11.  
  12. # import json
  13. import json
  14.  
  15. # import partial
  16. from functools import partial
  17.  
  18. # import trend
  19. from trend import twitter_trends
  20.  
  21. # import time_series
  22. from time_series import get_time_series_data
  23.  
  24. # import login, see http://blog.csdn.net/guaguastd/article/details/31706155
  25. from login import twitter_login
  26.  
  27. # get the twitter access api
  28. twitter_api = twitter_login()
  29.  
  30. # sample usage
  31. WORLD_WOE_ID = 1
  32. pp = partial(json.dumps, indent=1)
  33. twitter_world_trends = partial(twitter_trends, twitter_api, WORLD_WOE_ID)
  34.  
  35. # collect time series
  36. get_time_series_data(twitter_world_trends, 'time-series', 'twitter_world_trends')

RESULT:

  1. data:
  2. [{u'locations': [{u'woeid': 1, u'name': u'Worldwide'}], u'created_at': u'2014-07-17T22:46:34Z', u'_id': ObjectId('53c852dcae6f221648bfdde9'), u'trends': [{u'url': u'http://twitter.com/search?q=%23MH17', u'query': u'%23MH17', u'name': u'#MH17', u'promoted_content': None}, {u'url': u'http://twitter.com/search?
  3.  
  4. q=%23GazzeSiyonizmeMezarOlacak', u'query': u'%23GazzeSiyonizmeMezarOlacak', u'name': u'#GazzeSiyonizmeMezarOlacak', u'promoted_content': None}, {u'url': u'http://twitter.com/search?q=%23PrayForMH17', u'query': u'%23PrayForMH17', u'name': u'#PrayForMH17', u'promoted_content': None}, {u'url': u'http://twitter.com/search?
  5.  
  6. q=%23LouisWeLoveYou', u'query': u'%23LouisWeLoveYou', u'name': u'#LouisWeLoveYou', u'promoted_content': None}, {u'url': u'http://twitter.com/search?
  7.  
  8. q=%23SpamIsraelinTurkey', u'query': u'%23SpamIsraelinTurkey', u'name': u'#SpamIsraelinTurkey', u'promoted_content': None}, {u'url': u'http://twitter.com/search?q=%22MuhsinBa%C5%9Fkan+Erdo%C4%9Fan%C4%B1Desteklerdi%22', u'query': u'%22MuhsinBa%C5%9Fkan+Erdo%C4%9Fan%C4%B1Desteklerdi%22', u'name': u'MuhsinBa\u015fkan Erdo\u011fan\u0131Desteklerdi', u'promoted_content': None}, {u'url': u'http://twitter.com/search?
  9.  
  10. q=%22SoyunKurusun+Katilisrail%22', u'query': u'%22SoyunKurusun+Katilisrail%22', u'name': u'SoyunKurusun Katilisrail', u'promoted_content': None}, {u'url': u'http://twitter.com/search?q=%22IsraelIsSlaughtering+TheworldIsWatching%22', u'query': u'%22IsraelIsSlaughtering+TheworldIsWatching%22', u'name': u'IsraelIsSlaughtering TheworldIsWatching', u'promoted_content': None}, {u'url': u'http://twitter.com/search?
  11.  
  12. q=%22Elaine+Stritch%22', u'query': u'%22Elaine+Stritch%22', u'name': u'Elaine Stritch', u'promoted_content': None}, {u'url': u'http://twitter.com/search?
  13.  
  14. q=%22%C5%9EimdiDuaVakti+GazzeYan%C4%B1yor%22', u'query': u'%22%C5%9EimdiDuaVakti+GazzeYan%C4%B1yor%22', u'name': u'\u015eimdiDuaVakti GazzeYan\u0131yor', u'promoted_content': None}], u'as_of': u'2014-07-17T22:49:01Z'}]
  15.  
  16. Write 1 trends
  17. Zzz...
  18. data:
  19. [{u'locations': [{u'woeid': 1, u'name': u'Worldwide'}], u'created_at': u'2014-07-17T22:46:34Z', u'_id': ObjectId('53c8531eae6f221648bfddea'), u'trends': [{u'url': u'http://twitter.com/search?q=%23MH17', u'query': u'%23MH17', u'name': u'#MH17', u'promoted_content': None}, {u'url': u'http://twitter.com/search?
  20.  
  21. q=%23GazzeSiyonizmeMezarOlacak', u'query': u'%23GazzeSiyonizmeMezarOlacak', u'name': u'#GazzeSiyonizmeMezarOlacak', u'promoted_content': None}, {u'url': u'http://twitter.com/search?q=%23PrayForMH17', u'query': u'%23PrayForMH17', u'name': u'#PrayForMH17', u'promoted_content': None}, {u'url': u'http://twitter.com/search?q=%23LouisWeLoveYou', u'query': u'%23LouisWeLoveYou', u'name': u'#LouisWeLoveYou', u'promoted_content': None}, {u'url': u'http://twitter.com/search?
  22.  
  23. q=%23SpamIsraelinTurkey', u'query': u'%23SpamIsraelinTurkey', u'name': u'#SpamIsraelinTurkey', u'promoted_content': None}, {u'url': u'http://twitter.com/search?q=%22MuhsinBa%C5%9Fkan+Erdo%C4%9Fan%C4%B1Desteklerdi%22', u'query': u'%22MuhsinBa%C5%9Fkan+Erdo%C4%9Fan%C4%B1Desteklerdi%22', u'name': u'MuhsinBa\u015fkan Erdo\u011fan\u0131Desteklerdi', u'promoted_content': None}, {u'url': u'http://twitter.com/search?q=%22SoyunKurusun+Katilisrail%22', u'query': u'%22SoyunKurusun+Katilisrail%22', u'name': u'SoyunKurusun Katilisrail', u'promoted_content': None}, {u'url': u'http://twitter.com/search?q=%22IsraelIsSlaughtering+TheworldIsWatching%22', u'query': u'%22IsraelIsSlaughtering+TheworldIsWatching%22', u'name': u'IsraelIsSlaughtering TheworldIsWatching', u'promoted_content': None}, {u'url': u'http://twitter.com/search?q=%22Elaine+Stritch%22', u'query': u'%22Elaine+Stritch%22', u'name': u'Elaine Stritch', u'promoted_content': None}, {u'url': u'http://twitter.com/search?
  24.  
  25. q=%22%C5%9EimdiDuaVakti+GazzeYan%C4%B1yor%22', u'query': u'%22%C5%9EimdiDuaVakti+GazzeYan%C4%B1yor%22', u'name': u'\u015eimdiDuaVakti GazzeYan\u0131yor', u'promoted_content': None}], u'as_of': u'2014-07-17T22:50:08Z'}]
  26. Write 1 trends
  27. Zzz...
  28.  
  29. data:
  30. [{u'locations': [{u'woeid': 1, u'name': u'Worldwide'}], u'created_at': u'2014-07-17T22:46:34Z', u'_id': ObjectId('53c85361ae6f221648bfddeb'), u'trends': [{u'url': u'http://twitter.com/search?q=%23MH17', u'query': u'%23MH17', u'name': u'#MH17', u'promoted_content': None}, {u'url': u'http://twitter.com/search?q=%23GazzeSiyonizmeMezarOlacak', u'query': u'%23GazzeSiyonizmeMezarOlacak', u'name': u'#GazzeSiyonizmeMezarOlacak', u'promoted_content': None}, {u'url': u'http://twitter.com/search?q=%23PrayForMH17', u'query': u'%23PrayForMH17', u'name': u'#PrayForMH17', u'promoted_content': None}, {u'url': u'http://twitter.com/search?q=%23LouisWeLoveYou', u'query': u'%23LouisWeLoveYou', u'name': u'#LouisWeLoveYou', u'promoted_content': None}, {u'url': u'http://twitter.com/search?q=%23SpamIsraelinTurkey', u'query': u'%23SpamIsraelinTurkey', u'name': u'#SpamIsraelinTurkey', u'promoted_content': None}, {u'url': u'http://twitter.com/search?q=%22MuhsinBa%C5%9Fkan+Erdo%C4%9Fan%C4%B1Desteklerdi%22', u'query': u'%22MuhsinBa%C5%9Fkan+Erdo%C4%9Fan%C4%B1Desteklerdi%22', u'name': u'MuhsinBa\u015fkan Erdo\u011fan\u0131Desteklerdi', u'promoted_content': None}, {u'url': u'http://twitter.com/search?
  31.  
  32. q=%22SoyunKurusun+Katilisrail%22', u'query': u'%22SoyunKurusun+Katilisrail%22', u'name': u'SoyunKurusun Katilisrail', u'promoted_content': None}, {u'url': u'http://twitter.com/search?q=%22IsraelIsSlaughtering+TheworldIsWatching%22', u'query': u'%22IsraelIsSlaughtering+TheworldIsWatching%22', u'name': u'IsraelIsSlaughtering TheworldIsWatching', u'promoted_content': None}, {u'url': u'http://twitter.com/search?q=%22Elaine+Stritch%22', u'query': u'%22Elaine+Stritch%22', u'name': u'Elaine Stritch', u'promoted_content': None}, {u'url': u'http://twitter.com/search?q=%22%C5%9EimdiDuaVakti+GazzeYan%C4%B1yor%22', u'query': u'%22%C5%9EimdiDuaVakti+GazzeYan%C4%B1yor%22', u'name': u'\u015eimdiDuaVakti GazzeYan\u0131yor', u'promoted_content': None}], u'as_of': u'2014-07-17T22:51:15Z'}]
  33.  
  34. Write 1 trends
  35. Zzz...

Python 收集Twitter时间序列数据的更多相关文章

  1. python时间序列数据的对齐和数据库的分批查询

    欲直接下载代码文件,关注我们的公众号哦!查看历史消息即可! 0. 前言 在机器学习里,我们对时间序列数据做预处理的时候,经常会碰到一个问题:有多个时间序列存在多个表里,每个表的的时间轴不完全相同,要如 ...

  2. Python调用Prometheus监控数据并计算

    Prometheus是什么 Prometheus是一套开源监控系统和告警为一体,由go语言(golang)开发,是监控+报警+时间序列数 据库的组合.适合监控docker容器.因为kubernetes ...

  3. PIE SDK打开长时间序列数据

    1. 功能简介 时间序列数据(time series data)是在不同时间上收集到的数据,这类数据是按时间顺序收集到的,用于所描述现象随时间变化的情况.当前随着遥感卫星技术日新月异的发展,遥感卫星的 ...

  4. Python数据分析 之时间序列基础

    1. 时间序列基础 import numpy as np import pandas as pd np.random.seed(12345) import matplotlib.pyplot as p ...

  5. 利用python实现平稳时间序列的建模方式

    一.平稳序列建模步骤 假如某个观察值序列通过序列预处理可以判定为平稳非白噪声序列,就可以利用ARMA模型对该序列进行建模.建模的基本步骤如下: (1)求出该观察值序列的样本自相关系数(ACF)和样本偏 ...

  6. 时间序列数据的定义,读取与指数平滑(Java)

    应上头的要求,需要实现以下指数平滑进行资源调度负载的预测,那就是用我最喜欢的Java做一下吧. 引用<计量经济学导论>的一句话:时间序列数据区别于横截面数据的一个明显特点是,时间序列数据集 ...

  7. Python数学建模-02.数据导入

    数据导入是所有数模编程的第一步,比你想象的更重要. 先要学会一种未必最佳,但是通用.安全.简单.好学的方法. 『Python 数学建模 @ Youcans』带你从数模小白成为国赛达人. 1. 数据导入 ...

  8. 通过Python收集MySQL MHA 部署及运行状态信息的功能实现

    一. 背景介绍 当集团的MySQL数据库实例数达到2000+.MHA集群规模数百个时,对MHA的及时.高效管理是DBA必须面对的一个挑战.MHA 集群 节点信息 和 运行状态 是管理的基础.本篇幅主要 ...

  9. Python收集这些视频只是单纯的想做做壁纸,大家不要误会

    首先澄清一下,我用Python收集这些视频,绝不是想做别的什么,真的只是用来做动态壁纸,大家不要误会!我不是那样的人~ 这样的不过份吧 (这个动图看不看的到就看有没有缘分了 ) 阅读本文你需要准备 1 ...

随机推荐

  1. 重操JS旧业第十一弹:BOM对象

    BOM对象即浏览器内置对象,现今流行的浏览器内核有Safri,Firefox,Chrome,Opera,IE其中IE的兼容性是最蛋疼的在10及其过后还好点,但是现在IE基本上淘汰,而国内像360这种垃 ...

  2. Android-Cannot merge new index 66195 into a non-jumbo instruction的解决的方法

    转载请注明来源:http://blog.csdn.net/goldenfish1919/article/details/33729679 用eclispe打包的时候报错: [2014-06-23 13 ...

  3. APK扩展文件介绍、功能及用法

    APK扩展文件介绍 Android Market (Google Play Store)中每一个APK文件的最大限制是50MB.假设您的程序中包括大量的数据文件,曾经您仅仅能把这些数据文件放到自己的s ...

  4. Jrebel 6.2.1破解

    个人微信:benyzhous,可以一起探讨 云盘下载链接: http://pan.baidu.com/s/1bnGzMUF 配置: -noverify -javaagent:/Users/chabab ...

  5. unity3d ngui-TweenRotation-TweenPosition-TweenScale

    using UnityEngine; using System.Collections; public class TweenFlipCARDS : MonoBehaviour { private f ...

  6. eclipse3.2 汉化 汉化包下载

    1.首先去www.eclipse.org下载eclipse3.2   点击下载eclipse3.2 2.再去www.eclipse.org下载它的汉化包   请使用迅雷等下载工具下载汉化包 注意不同版 ...

  7. [Usaco2008 Dec]Patting Heads

    It's Bessie's birthday and time for party games! Bessie has instructed the N (1 <= N <= 100,00 ...

  8. linux下的块设备驱动(二)

    上一章主要讲了请求队列的一系列问题.下面主要说一下请求函数.首先来说一下硬盘类块设备的请求函数. 请求函数可以在没有完成请求队列的中的所有请求的情况下就返回,也可以在一个请求都不完成的情况下就返回. ...

  9. C#实现树的双亲表示法

    watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbHVja3k1MTIyMg==/font/5a6L5L2T/fontsize/400/fill/I0JBQk ...

  10. ZOJ3805:Machine

    In a typical assembly line, machines are connected one by one. The first machine's output product wi ...