Created
December 6, 2017 20:51
-
-
Save marcotc/8696d8a61c4072ade16b5e5f906da447 to your computer and use it in GitHub Desktop.
Finds latest TFSA limit published by CRA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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