Created
August 20, 2014 01:10
-
-
Save flavioamieiro/4efe0ef0fff213e83883 to your computer and use it in GitHub Desktop.
Get wordcloud from a document in PyPLN
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
#!/usr/bin/env python2 | |
# just give this script a document id (as in `$ python get_wordcloud.py 1`, for example) | |
# and it will download the wordcloud from PyPLN. | |
# | |
# Replace PYPLN_URL by the desired host. | |
import base64 | |
import sys | |
import pypln.api | |
doc_id = int(sys.argv[1]) | |
PYPLN_URL = 'http://localhost:8000' | |
doc = pypln.api.Document.from_url("{}/documents/{}/".format( | |
PYPLN_URL, doc_id), ("admin", "admin")) | |
with open("wordcloud_{}.png".format(doc_id), 'w') as fd: | |
fd.write(base64.b64decode(doc.get_property("wordcloud"))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment