In [1]:
from __future__ import print_function
import stackexchange #install this using easy_install: easy_install Py-StackExchange
import os
st = stackexchange.Site(stackexchange.StatisticalAnalysis, app_key=os.environ[SE_KEY]) #This is Theja's key, you should use your own
st.impose_throttling = True
st.throttle_stop = False
st.be_inclusive()
#Theja's Cross Validated Address: http://stats.stackexchange.com/users/30815/
theja = st.user(30815)
answers = theja.answers.fetch()
#dir(question)
In [7]:
import time
f_se_stats =open('../../_posts/2014-11-09-Stats-Stackechange.md', 'wb')#hardcoded date of the article.
f_se_stats.write('---\n')
f_se_stats.write('layout: post\n')
f_se_stats.write('title: "Theja\'s Stats.Stackexchange Footprint/Mirror" \n')
f_se_stats.write('---\n\n')
f_se_stats.write('\n\n\nHi folks! I took the opportunity to select out my answers to some stackexchange questions and reproduce them here. ')
f_se_stats.write(' The questions are by various users on Stackexchange and the answers are mine. ')
f_se_stats.write(' I have linked the original content in the question titles. The post is long because some of the questions are long :) . ')
f_se_stats.write(' I used Py-StackExchnage to generate this using a hackish python notebook. It is available [here](http://nbviewer.ipython.org/github/thejat/thejat.github.io/blob/master/static/scripts/StackexchangeDump.ipynb). ')
f_se_stats.write(' This list was generated on '+time.asctime( time.localtime(time.time()) )+'. Hope you find this a good read.\n\n\n')
counter = 0
for a in answers:
answer = st.answer(a.id)
question = st.question(answer.question_id)
counter +=1
f_se_stats.write('------\n')
f_se_stats.write('\n### Question ' + str(counter) + ': ')
f_se_stats.write('['+question.title.encode('utf-8')+']('+question.url+')')
f_se_stats.write('\n\n{% raw %}\n')
f_se_stats.write(question.body.encode('utf-8'))
f_se_stats.write('\n{% endraw%}\n\n')
f_se_stats.write('### My Answer:\n\n')
f_se_stats.write('{% raw %}\n')
f_se_stats.write(answer.body.encode('utf-8'))
f_se_stats.write('\n{% endraw%}\n\n\n\n\n')
f_se_stats.close()
In [4]: