Ejemplo n.º 1
0
#INPUT: location id (generated from Yhoo Earth Locator)
#OUPUT: Trends in the specified location

import find_trends as ft
import json
from au import flags,au
import twitter_acc_authorization as ta


flags.DEFINE_string('location_id',None,'Give location ID from Yahoo Earth Locator| WOE_ID')
flags.DEFINE_output('trends_json',None,'Returns the trends in the specified location')
flags.DEFINE_output('output_dir','','the output dir')


def main(args):
    t=ta.authorize()
    trends=ft.search_trends(t,au.FLAGS['location_id'])
    with open(au.OUTPUT['trends_json'],'w') as fh:
        json.dump(trends,fh,indent=1)

    
    if __name__=="__main__":
    au.run(main)
# INPUT: search terms(multiple search terms can be given)
# OUPUT: Tweets with metadata
# This function will return real time tweets related to the search term

import json
import tweet_stream as tsr
import json
import twitter_acc_authorization as ta
from au import flags,au

flags.DEFINE_string('stream_term','None','Enter the term or a series of comma separated terms to get the results')
flags.DEFINE_output('streamed_tweets',None,'real time streamed tweets in JSON format')
flags.DEFINE_output('output_dir','','the output dir') 

def main(args):
     streamed_tweets=tsr.tweet_stream(ta.authorize(),au.FLAGS['stream_term'])
     with open(au.OUTPUT['streamed_tweets'],'w') as fh:
        json.dump(streamed_tweets,fh,indent=1)

if __name__=="__main__":
    au.run(main)
# INPUT: Screen Name or User Id of the user
# OUTPUT: All the tweets of a user with some limitations. Refer the lib function get_user_tweet for it

from au import flags,au
import json
import twitter
import get_user_tweets as ut
import twitter_acc_authorization as ta

flags.DEFINE_string('ID',None,'Either Screen Name or User ID')
flags.DEFINE_output('user_tweets',None,'All the user tweets')
flags.DEFINE_output('output_dir','','The output dir') 

def main(args):
    full_user_tweets=ut.get_user_tweets(ta.authorize(),au.FLAGS['ID'])
    with open(au.OUTPUT['user_tweets'],'w') as fh:
        json.dump(full_user_tweets,fh,indent=1)
       

if __name__=="__main__":
    au.run(main)
Ejemplo n.º 4
0
# Inputs: Search term
# Output: Tweets in JSON format with complete metadata

import twitter
import json
from au import flags, au
import twitter_searchTweets as ts
import twitter_acc_authorization as ta

flags.DEFINE_string('search_term', None, 'Enter the keyword to search tweets')
flags.DEFINE_output(
    'tweets_with_metadata', None,
    'The tweets will complete information about it is returned')
flags.DEFINE_output('output_dir', '', 'The output dir')


def main(args):
    tweets_with_metadata = ts.search_tweets(ta.authorize(),
                                            au.FLAGS['search_term'])
    with open(au.OUTPUT['tweets_with_metadata'], 'w') as fh:
        json.dump(tweets_with_metadata, fh, indent=1)


if __name__ == "__main__":
    au.run(main)
Ejemplo n.º 5
0
import searchProfile
import ga_authorization as ga
from au import au, flags
import httplib2
import json
import apiclient.discovery

flags.DEFINE_string('search_term', None, 'Search Term')
flags.DEFINE_output('people_profile', None, "Person's profile is returned")
flags.DEFINE_output('output_dir', '', 'The output dir')


def main(args):
    service_key = ga.authorize()
    print service_key
    person_profile = searchProfile.searchF(service_key,
                                           au.FLAGS['search_term'])
    with open(au.OUTPUT['people_profile'], 'w') as fh:
        json.dump(person_profile, fh, indent=1)


if __name__ == "__main__":
    au.run(main)
#INPUT: Screen name or User Id
#OUTPUT: Complete user profile i.e. followers, tweets etc


import get_user_profile as up
from au import au,flags
import twitter
import json
import twitter_acc_authorization as ta

flags.DEFINE_separatedlist('screen_name',None,'Enter screen name')
flags.DEFINE_separatedlist('ID',None,'Either Screen name or user id')
#flags.DEFINE_string('screen_name',None,'ENter the screen name')
flags.DEFINE_output('user_profile',None,'Returns user profile in JSON format')
flags.DEFINE_output('output_dir','','The output dir')


def main(args):
    t=ta.authorize()
    print "The authorized token is %s"%t
    print au.FLAGS['screen_name']
    user_profile=up.get_user_profile(t,au.FLAGS['screen_name'],au.FLAGS['ID'])
    with open(au.OUTPUT['user_profile'],'w') as fh:
        json.dump(user_profile,fh,indent=1)

    
if __name__=="__main__":
    au.run(main)