if __name__ == '__main__':

    # Your query

    Q = ' '.join(sys.argv[1])

    # How many batches of data to grab for the search results

    MAX_BATCHES = 2

    # How many search results per page

    COUNT = 200

    # Get some search results for a query
    t = oauth_login()
    search_results = search(t, q=Q, max_batches=MAX_BATCHES, count=COUNT)
    g = create_rt_graph(search_results)

    # Write Protovis output and open in browser

    if not os.path.isdir('out'):
        os.mkdir('out')

    f = os.path.join(os.getcwd(), 'out', OUT)

    write_protovis_output(g, f, HTML_TEMPLATE)

    webbrowser.open('file://' + f)
Exemplo n.º 2
0
    # Get some search results for a query

    #twitter_search = twitter.Twitter(domain='search.twitter.com')

    search_results = []
    
  	for page in range(1, MAX_PAGES+1):
		    search_results += \
		        tweepy_search.search(q=Q, rpp=RESULTS_PER_PAGE, page=page)['results']
  
    all_tweets = [  tweet 
                    for page in search_results 
                        for tweet in page['results']
                 ]

    # Build up a graph data structure

    g = create_rt_graph(all_tweets)

    # Write Protovis output and open in browser

    if not os.path.isdir('out'):
        os.mkdir('out')

    f = os.path.join(os.getcwd(), 'out', OUT)

    write_protovis_output(g, f, HTML_TEMPLATE)

    webbrowser.open('file://' + f)
    OUT = 'twitter_retweet_graph.dot'

    # Your query

    Q = ' '.join(sys.argv[1])

    # How many batches of data to grab for the search results

    MAX_BATCHES = 2

    # How many search results per page

    COUNT = 100

    # Get some search results for a query
    t = oauth_login()
    search_results = search(t, q=Q, max_batches=MAX_BATCHES, count=COUNT)
    g = create_rt_graph(search_results)

    # Write Graphviz output

    if not os.path.isdir('out'):
        os.mkdir('out')

    f = os.path.join(os.getcwd(), 'out', OUT)

    write_dot_output(g, f)

    print >> sys.stderr, \
            'Try this on the DOT output: $ dot -Tpng -O%s %s' % (f, f,)