Last active
December 29, 2015 19:29
-
-
Save marcelcaraciolo/7717945 to your computer and use it in GitHub Desktop.
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
import urllib | |
import json | |
from pytagcloud import create_tag_image, make_tags | |
from pytagcloud.lang.counter import get_tag_counts | |
def search(): | |
url = 'https://api.foursquare.com/v2/venues/search?ll=-8.064329,-34.87315&oauth_token=<SEU_ACCESS_TOKEN>&v=20131130' | |
resp = urllib.urlopen(url).read() | |
data = json.loads(resp.decode('utf-8')) | |
return data['response']['venues'] | |
def tips(venue): | |
url ='https://api.foursquare.com/v2/venues/%s/tips?sort=recent&oauth_token=<SEU_ACCESS_TOKEN>v=20131130' | |
resp = urllib.urlopen(url % venue).read() | |
data = json.loads(resp.decode('utf-8')) | |
return data['response']['tips']['items'] | |
for venue in search(): | |
print (venue['name']) | |
texto_final = "" | |
for tip in tips(venue['id']): | |
texto_final += tip['text'] + ' ' | |
tags = make_tags(get_tag_counts(texto_final), maxsize=150) | |
create_tag_image(tags, '%s.png' % venue['name'].replace(' ', ''), size=(1024, 960), fontname='Lobster') | |
#import webbrowser | |
#webbrowser.open('%s.png' % venue['name'].replace(' ', '')) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment