This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
#* | |
* to install the needed twitter module please run: | |
* pip install python-twitter | |
*# | |
import twitter | |
from pprint import pprint | |
def main(): | |
"""..""" | |
api = twitter.Api(consumer_key="YOUR_KEY_HERE", | |
consumer_secret="YOUR_KEY_HERE", | |
access_token_key="YOUR_KEY_HERE", | |
access_token_secret="YOUR_KEY_HERE") | |
search = api.GetSearch("#f57", count=100, result_type="recent") | |
locations = {} | |
num = 0 | |
for _search in search: | |
num += 1 | |
location = _search.user.location.encode('utf-8') | |
if len(location) > 0: | |
if locations.get(location) is None: | |
locations[location] = [_search] | |
else: | |
locations[location] += [_search] | |
print "" | |
print "locations:" | |
for loc in locations: | |
print loc, len(locations[loc]) | |
for _search in locations[loc]: | |
print "text: {0}".format(_search.text.encode('utf-8')) | |
print "tweet url: https://twitter.com/{0}/status/{1}" \ | |
"".format(_search.user.screen_name.encode('utf-8'), _search.id) | |
print "========" | |
print '----' | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment