Class: Cantonese::Scraper::RadicalScraper

Inherits:
Object
  • Object
show all
Defined in:
lib/cantonese/scraper/radical_scraper.rb

Overview

get radical from moedict-webkit site

Instance Method Summary collapse

Instance Method Details

#crawlObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/cantonese/scraper/radical_scraper.rb', line 7

def crawl
  json = open("https://raw.githubusercontent.com/audreyt/moedict-webkit/master/c/@.json").read

  result = []
  id = 1
  data = JSON(json)
  data.each_with_index do |radicals, index|
    radicals.each do |radical|
      result << {:name => radical, :stroke => index, :id => id}
      id = id + 1
    end
  end
  result
end