2019-01-24 20:44:33 Ruby

Ruby

Copy Copied! Full
#kaizen require "uri";require "open-uri" puts "*plz type something*" begin loop do if (word=gets.chomp.to_s)==nil;puts "*駄目: tabu,taboo*";next else puts "*Well, let me see...*" unless word =~ /^[a-zA-Z]+$/;puts "*日本語: Japanese*";next else begin open(URI.encode("https://ejje.weblio.jp/content/#{word}")){|mean| data=mean.read.scan(/learning-level-table-wrap(.*)語彙力テストを受ける/).flatten[0] .scan(/>(.*?)</).flatten.delete_if{|a|a==""} puts "Level:#{data[2]}/英検:#{data[5].scan(/\w+/)[0]}級↑/#{data[8]}/TOEIC:#{data[11].scan(/\d+/)[0]}↑/#{data[-1]}/" } rescue NoMethodError;puts '*none: (…の)いずれも…ない,どれも…ない,少しも…ない,…はよせ,やめなさい,だれも…ない*';end if word == "exit" ||word == "end" ||word == "finish";sleep(3);exit;end end end end rescue Interrupt puts '*interrupt: (…を)さえぎる,中断する,腰を折る*' end