Skip to content

Instantly share code, notes, and snippets.

@ifesdjeen
Created September 25, 2011 09:26
Show Gist options
  • Save ifesdjeen/1240416 to your computer and use it in GitHub Desktop.
Save ifesdjeen/1240416 to your computer and use it in GitHub Desktop.
export your custom dictionary to iknow
# -*- coding: utf-8 -*-
require 'rubygems'
require 'capybara'
require 'capybara/dsl'
Capybara.run_server = false
Capybara.default_driver = :selenium
Capybara.app_host = 'http://iknow.jp'
class IKnowExporter
include Capybara
def iknow_export
puts 'Logging in...'
visit('/login')
within 'form' do
fill_in 'login_user_email', with: '' # your email here
fill_in 'login_user_password', with: '' # your password here
end
page.find("#login_user_submit").click # list of your words here
words = [ {:word=>"abfahren", :translation=>"to depart"} ]
words.each do |word|
puts "Processing #{word}."
visit('/custom/courses/____') # url of your custom course
page.find(".add_item").click
within 'form' do
fill_in "item_cue_text", with: word[:word]
fill_in "item_response_text", with: word[:translation]
end
page.find("#item_submit").click
sleep 2
end
end
end
t = IKnowExporter.new
t.iknow_export
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment