Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/env python
- # -*- coding: utf-8 -*-
- """
- a twitter mining app
- note this requires twitter api
- """
- import twitter
- import json
- # these four cannot be empty
- CONSUMER_KEY = ''
- CONSUMER_SECRET = ''
- OAUTH_TOKEN = ''
- OAUTH_TOKEN_SECRET = ''
- auth = twitter.oauth.OAuth(OAUTH_TOKEN, OAUTH_TOKEN_SECRET,
- CONSUMER_KEY, CONSUMER_SECRET)
- twitter_api = twitter.Twitter(auth=auth)
- print twitter_api
- # this is found via a yahoo api
- WORLD_WOE_ID = 1
- PH_WOE_ID = 23424934
- world_trends = twitter_api.trends.place(_id=WORLD_WOE_ID)
- ph_trends = twitter_api.trends.place(_id=PH_WOE_ID)
- world_trends_set = set ([trend['name']
- for trend in world_trends[0]['trends']])
- ph_trends_set = set([trend['name']
- for trend in ph_trends[0]['trends']])
- common_trends = world_trends_set.intersection(ph_trends_set)
- print json.dumps(world_trends, indent=1)
- print
- print json.dumps(ph_trends, indent=1)
- print common_trends
- # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement