Python 提取Twitter转发推文的元素(比方username)
2015-12-22 19:09
399 查看
CODE:
RESULT:
#!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on 2014-7-24 @author: guaguastd @name: extract_retweet_attributions.py ''' if __name__ == '__main__': # import login, see http://blog.csdn.net/guaguastd/article/details/31706155 from login import twitter_login # get the twitter access api twitter_api = twitter_login() # import search from search import twitter_search # import extract_retweet_id from tweet import extract_retweet_id, get_rt_attributions while 1: query = raw_input('\nInput the query (eg. #MentionSomeoneImportantForYou, exit to quit): ') if query == 'exit': print 'Successfully exit!' break search_results = twitter_search(twitter_api, query, max_results=1) #print search_results, # Get the retweet id retweets_id = extract_retweet_id(search_results) #print retweets_id, # Get the retweet attribution for rid in retweets_id: tweet = twitter_api.statuses.show(_id=rid) print get_rt_attributions(tweet) print
RESULT:
Input the query (eg. #MentionSomeoneImportantForYou, exit to quit): Core Python Length of statuses 60 [u'ritzylivingwage']
相关文章推荐
- Python socket编程
- secondpostinpython
- Python Wing IDE5.1.8-1 KeyGen
- firstpostinpython
- Python基础06 循环
- Python基础05 缩进和选择
- Python基础04 运算
- Python基础03 序列
- Python基础02 基本数据类型
- Python基础01 Hello World!
- wxPython+Matplotlib
- python实例编写(6)--引入unittest测试框架,构造测试集批量测试(以微信统一管理平台为例)
- python和unicode
- [置顶] 建议53:用状态模式美化代码,关于python-state工具包的理解
- Python 动态创建函数【转】
- 如何用 Python 爬取需要登录的网站
- ldap服务器搭建——python认证接口
- Python的模块
- Python连接MySQL中有关中文乱码的解决问题
- WEB开发=(自带web服务器)django+python快速体验局域网内WEB开发