How python extracts tweets from Twitter-specific topics

Source: Internet
Author: User
Tags exit

CODE:

#!/usr/bin/python #-*-Coding:utf-8-*-' Created on 2014-7-7 @author: guaguastd @name: User_retweet _statuses.py ' if __name__ = = ' __main__ ': # import login, and so on Http://blog.csdn.net/guaguastd/ar ticle/details/31706155 from login Import Twitter_login # Get the Twitter access API Twitter_api = Twitter_login () # import search from search import search_for_tweet # import TWE Et from tweet import extract_retweet_id # pip install prettytable #from prettytable import Pr ettytable while 1:query = Raw_input (' \ninput ' query (eg. #MentionSomeoneImportantForYou, ex
            it to quit): ' If query = = ' exit ': print ' successfully exit! ' Break statuses = Search_for_tweet (twitter_api, query) Retweet_ids = extract_retweet_id (st atuses) FOr retweet_id in retweet_ids: _retweets = twitter_api.statuses.retweets (id=retweet_id) Print [ r[' user ' [' screen_name '] for R in _retweets]

Result:

Input the query (eg. #MentionSomeoneImportantForYou, exit to quit): #MentionSomeoneImportantForYou Length of statuses 1  
statuses [u ' kissmyasshton_ '] [u ' idkdallasbae ', U ' catarina5sos1d ', U ' Elenabomerc '] [u ' manu_19x ']  
[u ' idkdallasbae ', U ' catarina5sos1d ', U ' ELENABOMERC ']  
[u ' Xrayfux ']  
[u ' Paynashton ', U ' gellystyles ']  
[u ' Paynashton ', U ' gellystyles ']  
[u ' idkdallasbae ', U ' catarina5sos1d ', U ' ELENABOMERC ']  
[u ' Soulfullybutera ']  
[u ' Drewxhemmo ']  
[u ' Drewxhemmo ']  
[u ' Weirdbutera ']  
[u ' Demisbearx ']  
[u ' Kidrauhlogrande ']  
[u ' lonarryfeelsve ']  
[u ' lesxfleurs ']  
[u ' Flowerlyariana ']  
[u ' findanusername ']  
[u ' osnapitzjasmin ']  
[u ' blebersking ', U ' jileyfckn ']  
[u ' Sassymccann ']  
[u ' buterakisss ']  
[u ' blebersking ', U ' jileyfckn ']  
[u ' Michaelscobain ']  
[u ' Versxce5sos ']  
[u ' jdbftvamps_ ']  
[u ' Aridelreys ']  
[u ' Grandeamaze ']  
[u ' Arianastralia ']  
[u ' Heelsbutera ']  
[u ' Cliffords_taco ']  
[u ' Snowinboca ']  
[u ' avonkitties ']  
[u ' OHSNAPITZISAA '] [u ' DAA_BIEBSS '] 
[u ' Pinkunicornari '] Input the query (eg. #MentionSomeoneImportantForYou, exit to quit):

Back to the column page: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/extra/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.