Skip to content

Instantly share code, notes, and snippets.

@marcelcaraciolo
Last active December 29, 2015 19:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcelcaraciolo/7717945 to your computer and use it in GitHub Desktop.
Save marcelcaraciolo/7717945 to your computer and use it in GitHub Desktop.
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