class Scrapper

Public Class Methods

new(login="", senha="") click to toggle source
# File lib/scrapper_bovespa/scrapper.rb, line 6
def initialize(login="", senha="")
        @login = login
        @senha = senha
        @webservice = "http://webfeeder.cedrofinances.com.br"
end

Public Instance Methods

connect_to_bovespa() click to toggle source
# File lib/scrapper_bovespa/scrapper.rb, line 12
def connect_to_bovespa()
        post("SignIn?login=#{@login}&password=#{senha}")
end
get(command) click to toggle source
# File lib/scrapper_bovespa/scrapper.rb, line 16
def get(command)
        Net::HTTP.get(URI("#{@webservice}/#{command}"))
end
get_company_data() click to toggle source
# File lib/scrapper_bovespa/scrapper.rb, line 31
def get_company_data()
        proxy = ScrapeCompanys.new()
        cvms = proxy.get_cvms()
        output = []

        cvms.each do |cvm|
                output << proxy.get_company_data(cvm)
        end

        output.to_json
end
get_quotes(ticker) click to toggle source
# File lib/scrapper_bovespa/scrapper.rb, line 26
def get_quotes(ticker)
        #has to handle invalid data, need to test that
        eval(get("services/quotes/quote/#{ticker}"))
end
post(command) click to toggle source
# File lib/scrapper_bovespa/scrapper.rb, line 20
def post(command)
        uri = URI("#{@webservice}/#{command}")
        request = Net::HTTP::Post.new(uri)
        Net::HTTP.start(uri.hostname, uri.port)
end