Last active
June 20, 2019 22:04
-
-
Save bor8/bd9fe0ccf0d1ef341645b2847a4e2e0c 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
# pip3 install requests | |
import base64 | |
import json | |
import requests | |
some_text = 'blah blub blah dings abc abc abc usw hehe hehe hehe hehe hehe hehe' | |
response = requests.post("https://textvis-word-cloud-v1.p.rapidapi.com/v1/textToCloud?max_words=1000", | |
headers={ | |
"X-RapidAPI-Host": "textvis-word-cloud-v1.p.rapidapi.com", | |
"X-RapidAPI-Key": "<YOUR_KEY>", | |
"x-api-key": "<YOUR_KEY>", | |
"Content-Type": "application/json" | |
}, | |
json=json.loads('{"text":"' + some_text + '","scale":1.0,"width":1500,"height":800,"font":"Tahoma","use_stopwords":true,"language":"en","uppercase":false}') | |
) | |
# print(dir(response)) | |
rb = response.content | |
getrennt = rb.split(b',') | |
if len(getrennt) != 2: | |
raise Exception('lol') | |
header = getrennt[0] | |
encoded = getrennt[1] | |
imgdata = base64.b64decode(encoded) | |
with open('/tmp/keyphrases.png', 'wb') as f: | |
f.write(imgdata) | |
# Execute with python3 or py -3 on Windows. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment