title: How to insert data in DB (SQLite3 or sth) after parsing through casperjs?
body: <p>I'm new at ruby on rails and casperjs!</p>
  
  <p>I wrote code that parsing a lot of words (innerHTML) from some webpages.</p>
  
  <p>and I know how to run this code and I can check data in bash terminal</p>
  
  <p>But I don't know how to insert this data directly in my DB (now i'm using SQLite3)</p>
  
  <p>Here is my js code...(filename : application.js)</p>
  
  <pre><code>var words = [];
  var casper = require('casper').create();
  
      function getWords() {
          var words = document.querySelectorAll('td.subject a');
          return Array.prototype.map.call(words, function(e) {
              return e.innerHTML;
          });
      }
  
  
          casper.start('http://www.todayhumor.co.kr/board/list.php?table=bestofbest', function() {
              // search for 'casperjs' from google form
              words = this.evaluate(getWords);
          });
  
          for (var i=2; i &lt;=5; i++) {
          casper.thenOpen('http://www.todayhumor.co.kr/board/list.php?table=bestofbest&amp;page='+i, function() {
              // search for 'casperjs' from google form
  
              words = words.concat(this.evaluate(getWords));
          });
          }
  
      casper.run(function() {
          // echo results in some pretty fashion
          this.echo(words.length + ' links found:').exit();
          this.echo(words.join('\n')).exit();
  });
  </code></pre>
  
  <p>and </p>
  
  <p>I run this code through terminal like this!</p>
  
  <pre><code>username@wow:~/workspace/app/assets/javascripts $ casperjs application.js
  </code></pre>
  
  <p>and the result is <em>(for example)</em></p>
  
  <pre><code>Fontconfig warning: ignoring C.UTF-8: not a valid language tag
  150 words found:
  word1
  word2
  word3
  word4
  word5
  word6
  word7
  word8
  word9
  ...
  </code></pre>
  
  <p>maybe the number of words is over <strong>7,000,000</strong>!</p>
  
  <p>So I want to insert this data in my DB table(seed.rb file)</p>
  
  <p>tell you more details, the db table is consist of 3 columns and will have many rows(<strong>7,000,000</strong> of parsing data)</p>
  
  <p>here is my code of file in migrate directory and <strong>I want to insert words that I parsed in column2(:word)!!</strong></p>
  
  <pre><code>class CreateFans &lt; ActiveRecord::Migration
    def change
      create_table :fans do |t|
         t.string :type
         t.string :word
         t.string :spelling
  
        t.timestamps null: false
      end
    end
  end
  </code></pre>
  
  <p>and this is codes of <code>seeds.rb</code> <em>(for example)</em></p>
  
  <pre><code>my_initial_words = [
                      ['fruits', 'apple', 'ap'],
                      ['fruits', 'banana', 'ba'],
                      ['fruits', 'kiwi', 'ki'],
                      ['fruits', 'melon', 'me'],
                      ['foods', 'cake', 'ca'],
                      ['foods', 'pizza', 'pi'],
                      ['foods', 'hamburger', 'ha'],
                      ['foods', 'hotdog', 'ho'],
                      ['foods', 'toast', 'to']                        
                    ]    
  my_initial_words.each do |word_data|
    Fan.create(type: word_data[0], word: word_data[1], spelling: word_data[2])
  end
  </code></pre>
  
  <p>As a conclusion, I'd like to know how to insert parsing data(through casperjs) directly in my DB seed file! or are there any good way to save the data??</p>
  
  <p>Thanks for read my long question!</p>