{
require 'open-uri'require 'nokogiri'
require 'openssl'
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
class Opgg < ApplicationRecord
url = "https://www.op.gg/statistics/champion/"
#Nokogiri::HTML::ParseOptions::NOBLANKS
data = Nokogiri::HTML(open(url), nil, 'UTF-8')
@opggs = data.css('div#ChampionStatsTable')
@opggs.each do |opgg|
Opgg.create(
:cname => opgg.css('table tr td').text.strip,
:rate => opgg.css('table tr td.Cell').text.strip,
:gnum => opgg.css('table tr td.Cell').text.strip,
:kda => opgg.css('table tr td span.Ratio').text.strip,
:cs => opgg.css('table tr td.Cell span').text.strip,
:gold => opgg.css('table tr td.Cell span').text.strip
)
end
end}
I'm practicing parsing with nokogiri, and trying to parse '
op.gg/' site. But i can't get results i want. What's problem with my code?