laxxy
Member
Registered: 2006-07-19
Posts: 203
Is it possible to export all stories you wrote into, e.g., a text file or a spreadsheet?
Such an ability would definitely be most helpful.
i'd like to echo this request. before discovering this website, i had written all my stories from RTK1 in a notebook, but now that i've found more memorable stories and am able to input my own into an internet-accessable collection, it would be great to be able to have printable lists generated for making a new notebook, or even generate a PDF in a format similar to RTK1 that could be used for review of our stories offline. This kind of output would make the input of our stories into this website more complete and worthwhile, especially in the case that the server data is corrupted somehow.
Although this would be a time-consuming undertaking, I hope it is deemed worthwhile. Regardless, I am boundlessly thankful for the usefulness of this website and forum.
rtkrtk
Member
From: Japan
Registered: 2007-10-16
Posts: 27
Here is an export script. I've hard-coded a delay of 60 seconds between requests to prevent hammering the server too hard. Don't abuse this script or our beloved site will die under the stress 
To use it, save the script to a file e.g. export.py, edit the parameters username, password, startingKanji, and endingKanji, and run it with "python export.py". The output is in a comma-separated file "stories.txt" which can probably be imported into any spreadsheet. The file is written incrementally (closed and re-opened) after every kanji story is fetched, so even if the program crashes in the middle of downloading, you should still be able to read all of the stories downloaded so far.
Are there bugs? Probably. Will this script fail if the website changes formatting? Definitely.
Enjoy. Code is public domain.
#!/usr/bin/env python
################## start of user-configurable parameters ######################
username="YOURNAME"
password="YOURPASSWORD"
startingKanji = 205
endingKanji = 210
outputFilename = "stories.txt"
delay=60
################## end of user-configurable parameters #######################
from ClientForm import ParseResponse
from ClientCookie import urlopen
import re
import time
outfile = open(outputFilename,"w")
response = urlopen("http://kanji.koohii.com/login.php")
forms = ParseResponse(response, backwards_compat=False)
form = forms[0]
form["uname"] = username
form["passwd"] = password
urlopen(form.click()).read()
for ikanji in range(205,210):
kanjiurl="http://kanji.koohii.com/study/?mode=failed&framenum=%d" % (ikanji)
rawtext = urlopen(kanjiurl).read()
match_keyword = re.search('(<div class="keyword">)([^<]*)(</div>)',rawtext)
if(match_keyword):
g = match_keyword.groups()
keyword = g[1]
match_story = re.search('(id="frmStory">)(.*)(</textarea>)',rawtext)
if(match_story):
g = match_story.groups()
story = g[1]
outstring = '%d,"%s","%s"' % (ikanji, keyword, story)
outfile.write(outstring+"\n")
outfile.close()
outfile = open(outputFilename,"a")
print outstring
time.sleep(delay)
outfile.close()
iSoron
Member
From: Canada
Registered: 2008-03-24
Posts: 490
shinkyu wrote:
I have loaded this script too but it doesnt seem to do anything when I click the "export button" - has something changed or am I missing something?
Still works fine here.
Are there any errors in Firefox error console when you click the button?
this_is_douglas wrote:
I have tried the Greasemonkey script but it doesn't seem to be working sad I'm using Opera and User-scripts but it's the same principle ... has the coding changed to make it not work, or am I being a n00b?
It's possible to create scripts that work both on Firefox and Opera, but I was a bit lazy at the time, and coded it specifically to Firefox. Sorry. I may fix it later. 
ファブリス wrote:
There ought to be a way to export your stories. I don't want to write this now on the old codebase, so I've put it on the refactoring to-do list as this should be fairly simple to add. The refactored site should be online before the end of April *fingers crossed*.
That would be great.
No more workarounds.
Last edited by iSoron (2009 April 02, 12:08 pm)