Posted on Sat 30 July 2016

# WaniKani on Anki

has long been my favorite way of studying Kanji, but I've always disliked the need to type in every single reading and meaning. At 300 reviews a day that's a lot of typing!

Today I finally had enough. First I considered making a user script for WaniKani to make it work a bit more like Anki (where you don't type the answer at all, you simply indicate how well you knew it with one tap). But then I realized that I might as well just use Anki directly.

I quickly found , which is great to export all Radicals, Kanji and Vocabulary and has really nice Anki templates too. Alas, the exported data didn't include the critical mnemonics! Presumably because these aren't returned by WaniKani's API.

Luckily, WaniKani is almost trivial to scrape:

import requests
from bs4 import BeautifulSoup

s = requests.Session()
'html.parser')
'authenticity_token': token})

page = BeautifulSoup(page, 'html.parser')
section = [t for t in page.find_all('section') if 'Mnemonic' in t.text][0]
return u''.join([unicode(t) for t in section.p.children])

def dump_kanji_mnemonics(kanji):
def get_mnemonic(kind):
section = [t for t in page.find_all('section')
if '%s Mnemonic' % kind in t.text][0]
return u''.join([unicode(t) for t in section.p.children])
page = s.get('https://www.wanikani.com/kanji/%s' % kanji).text
page = BeautifulSoup(page, 'html.parser')
return u'<b>Reading</b>: %s<br><b>Meaning</b>: %s' % (


Then I simply looped through the CSV files from wanikanitoanki and fetched the mnemonic for each, then added them as an extra column to the CSVs.

I only had to slightly modify the Anki card template to include the mnemonics.

For the back template, I added:

<br/>
{{#mnemonic}}<div class="kunyomi">{{mnemonic}}</div>{{/mnemonic}}


I also took advantage of the fact that the mnemonics fetched from WaniKani include <span> tags to highlight the Kanji / Radical they are talking about by adding some extra CSS:

.kanji-highlight {
background-color: #f100a0;
}

background-color: #555;
}

background-color: #00a0f1;
}