2011.09.18 01:05
how to rip flashcards from www.flashcardexchange.com
This is a Python script to rip flashcards from www.flashcardexchange.com :
#!/usr/bin/env python
# This is the tool to download flashcards from www.flashcardexchange.com
# Usage: ./flashcardsexchange_dl.py URL
# For example:
# ./flashcardsexchange_dl.py http://www.flashcardexchange.com/flashcards/list/337131
import sys
from urllib import urlopen
import json
for line in urlopen(sys.argv[1]):
line = line.strip()
if len(line) > 0 and line[-1] == ',':
line = line[:-1]
try:
card = json.loads(line)
except ValueError:
pass
else:
print "%s;%s" % (card['question'], card['answer'])
komentarze:
powrót na stronę główną
RSS