Skip to content

Instantly share code, notes, and snippets.

@marcotc
Created December 6, 2017 20:51
Show Gist options
  • Save marcotc/8696d8a61c4072ade16b5e5f906da447 to your computer and use it in GitHub Desktop.
Save marcotc/8696d8a61c4072ade16b5e5f906da447 to your computer and use it in GitHub Desktop.
Finds latest TFSA limit published by CRA
require 'wombat'
require 'date'
data = Wombat.crawl do
base_url "https://www.canada.ca"
path "/en/revenue-agency/services/tax/individuals/frequently-asked-questions-individuals/adjustment-personal-income-tax-benefit-amounts.html"
limit xpath: "/html/body/main/div[1]/div[2]/div/table/tbody/tr[45]/td[2]"
year css: ".active > th:nth-child(2)"
end
year = Date.new(data["year"].to_i,1,1)
if year > Date.today
# New year's data!
limit = data["limit"].gsub(',','').to_i
puts "Found new TFSA limit data for #{year.year}: $#{limit} CAD"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment