Skip to content

Instantly share code, notes, and snippets.

@NP-chaonay
Last active July 27, 2020 06:33
Show Gist options
  • Save NP-chaonay/11b3b2f737a3a253a2599e88963f3fea to your computer and use it in GitHub Desktop.
Save NP-chaonay/11b3b2f737a3a253a2599e88963f3fea to your computer and use it in GitHub Desktop.
Mentimeter Wordcloud Question Scraping
# Mentimeter Wordcloud Question Scraping
import http.client,json
import pandas as pd
question_id='000000000000'
HTTP_C=http.client.HTTPSConnection('api.mentimeter.com')
HTTP_C.request('GET','/questions/'+question_id+'/result?isPublic=true')
HTTP_R=HTTP_C.getresponse()
data=HTTP_R.read()
data=json.loads(data)
data=data['results']
words_bin=[]
for word in words: words_bin+=[word]
for respondent in data:
words=respondent.split()
df=pd.DataFrame(words_bin)[0].value_counts().agg([lambda x: 100*x/len(words_bin),lambda x: x])
df.columns=['%','count']
df.nlargest(10,'count','all')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment