Skip to content

Instantly share code, notes, and snippets.

@codingjester
Created August 28, 2013 13:55
Show Gist options
  • Save codingjester/6366311 to your computer and use it in GitHub Desktop.
Save codingjester/6366311 to your computer and use it in GitHub Desktop.
Scraping the totalMarketValue of your E*Trade account. Probably could be better. You pass in your username/password as arguments to the script.
require 'mechanize'
a = Mechanize.new
a.get('https://us.etrade.com/home') do |page|
mypage = page.form_with(:action => '/login.fcc') do |f|
f.USER = ARGV[0]
f.PASSWORD = ARGV[1]
end.click_button
end
body = a.get("https://us.etrade.com/e/t/stockplan/overview?ploc=c-MainNav").body
result = body.split("\n").grep(/summaryWidget\.totalMarketValueRaw/).first
value = result.strip!.split(" = ")[1].gsub(/[";]/, '')
puts value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment