Last active
December 27, 2015 20:49
-
-
Save zetter/7387018 to your computer and use it in GitHub Desktop.
Halifax Online Banking Transaction Downloader Applescript
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
(* | |
Halifax Online Banking Transaction Downloader Applescript | |
https://gist.github.com/zetter/7387018 | |
To use: | |
+ Set the path to an existing directory where you want to save the | |
pages. | |
+ Open Safari with a single window and tab and login to Halifax Online. | |
+ Load up the first page of the transactions for the account you want to save. | |
+ Run this script. | |
I reccomend not running arbitary scripts in your browser, especially if it has | |
access to your bank's website. Please read through first. | |
*) | |
set myNumber to 1 | |
set myPages to 300 | |
tell application "Safari" | |
repeat myPages times | |
set mySource to "" | |
repeat while (mySource does not contain "</html>") | |
set mySource to source of current tab of first window | |
end repeat | |
set myFile to (POSIX file "/Users/zetter/transactions/" & (myNumber as text) & ".html") | |
my writeToFile(mySource, myFile) | |
do JavaScript "document.getElementById('pnlgrpStatement:conS1:frmVSPUpper:btnViewPreviousStatement').click(); " in current tab of first window | |
delay 0.1 | |
repeat while ((do JavaScript "document.readyState" in current tab of first window) ≠ "complete") | |
delay 0.1 | |
end repeat | |
set myNumber to myNumber + 1 | |
end repeat | |
end tell | |
on writeToFile(this_data, target_file) | |
set the target_file to the target_file as text | |
set the open_target_file to open for access file target_file with write permission | |
set eof of the open_target_file to 0 | |
write this_data to the open_target_file starting at eof | |
close access the open_target_file | |
return true | |
end write_to_file | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment