Created
February 1, 2024 21:21
-
-
Save dalepotter/e4d802b7d68f61f0adf571aa8e55b639 to your computer and use it in GitHub Desktop.
Download Assetz Capital balance CSV files from a given date.
This file contains hidden or 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
// Open a browser and login to the Assetz Capital Investors portal | |
// In the investor portal, navigate to Statements -> Account balances | |
// Open a debug console and copy/paste the following code | |
// Set configutation variables | |
startDate = '2018-05-01' | |
numMonthsToAdd = 69 // Adjust the monthsToAdd as required. '2018-05-01' + 69 months = 2024-01-01 | |
timezone = 'Europe/London' | |
// Function to delay execution | |
function delay(ms) { | |
return new Promise(resolve => setTimeout(resolve, ms)); | |
} | |
// Async function to generate URLs and "navigate" to them | |
async function generateAndVisitUrls(startDate, monthsToAdd) { | |
let currentDate = new Date(startDate); | |
for (let i = 0; i < monthsToAdd; i++) { | |
// Generate the URL | |
let year = currentDate.getFullYear(); | |
let month = String(currentDate.getMonth() + 1).padStart(2, '0'); // JS months are 0-based | |
let day = String(currentDate.getDate()).padStart(2, '0'); | |
let urlString = `https://investors.assetzcapital.co.uk/api/lender/balances/${year}-${month}-${day}?userTimezone=Europe/London&csv=true`; | |
// Visit the URL | |
window.location.replace(urlString); | |
// Wait for 5 seconds before continuing | |
await delay(5000); | |
// Move to the next month | |
currentDate.setMonth(currentDate.getMonth() + 1); | |
} | |
} | |
// Start the process from the desired start date, for as many months as needed | |
generateAndVisitUrls(startDate, numMonthsToAdd); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment