require 'nokogiri'
require 'mechanize'

class SCPArticleLoader
  def initialize(item_no, option)
    @item_no = item_no
    @option = option
    @agent = Mechanize.new
    url = "http://#{@option[:locale]}.scp-wiki.net/scp-#{@item_no}"
    page = @agent.get(url)
    doc = Nokogiri::HTML(page.content.toutf8)
    @article = doc.xpath('//*[@id="page-content"]').first
    @title = nil
  end

  def title()
    return @title if @title
    series = @item_no.to_i / 1000 + 1
    url = "http://www.scp-wiki.net/scp-series" +
      (series > 1 ? "-#{series}" : "")
    page = @agent.get(url)
    doc = Nokogiri::HTML(page.content.toutf8)
    article = doc.at('//*[@class="content-panel standalone series"]')
    @title = article.text.match("SCP-#{@item_no} - (.*)$").to_s
  end

  def article()
    return @article
  end
end

require 'nokogiri'
require 'mechanize'
require_relative 'locale'

class SCPArticleLoader
  def initialize(item_no, option)
    @item_no = item_no
    @option = option
    @agent = Mechanize.new
    url = "http://#{get_endpoint(@option[:locale])}/scp-#{@item_no}"
    page = @agent.get(url)
    doc = Nokogiri::HTML(page.content.toutf8)
    @article = doc.xpath('//*[@id="page-content"]').first
    @title = nil
  end

  def title()
    return @title if @title
    series = @item_no.to_i / 1000 + 1
    url = "http://www.scp-wiki.net/scp-series" +
      (series > 1 ? "-#{series}" : "")
    page = @agent.get(url)
    doc = Nokogiri::HTML(page.content.toutf8)
    article = doc.at('//*[@class="content-panel standalone series"]')
    @title = article.text.match("SCP-#{@item_no} - (.*)$").to_s
  end

  def article()
    return @article
  end
end

Support the other SCP Databases
Support the other SCP Databases

the other SCP Databases are:
* SCP-RU
* SCP-KO
* SCP-CN
* SCP-FR
* SCP-PL
* SCP-ES
* SCP-TH
