Skip to content

Instantly share code, notes, and snippets.

@pricees
Created October 9, 2013 12:54
Show Gist options
  • Select an option

  • Save pricees/6900781 to your computer and use it in GitHub Desktop.

Select an option

Save pricees/6900781 to your computer and use it in GitHub Desktop.
Morningstar Scraper in progress
require 'rubygems'
require 'capybara'
require 'capybara/dsl'
require "selenium-webdriver"
Capybara.run_server = false
Capybara.app_host = 'http://financials.morningstar.com'
Capybara.register_driver :auto_dl do |app|
profile = Selenium::WebDriver::Firefox::Profile.new
profile["browser.download.useDownloadDir"] = true
profile['browser.download.dir'] = "/tmp/webdriver-downloads"
profile['browser.download.folderList'] = 0 # 0 = desktop 2
profile["browser.helperApps.neverAsk.saveToDisk"] = "text/plain, application/csv, application/vnd.ms-excel, text/csv, text/comma-separated-values, application/octet-stream"
Capybara::Selenium::Driver.new(app, browser: :firefox, :profile => profile)
end
#Capybara.default_driver = :auto_dl
#Capybara.javascript_driver = :auto_dl
Capybara.current_driver = :auto_dl
module MyCapybaraTest
class Test
include Capybara::DSL
def test_morning_star(symbol)
visit "/income-statement/is.html?t=#{symbol}"
within(".icon_1_span") do
click_link('')
end
end
end
end
t = MyCapybaraTest::Test.new
%w[OUTR AAPL MSFT GLNG].each { |symbol| t.test_morning_star(symbol); exit }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment