I am trying to download the data from a public database. The webpage has a table, and whenever you click on a button "next", all of the rows are updated with new values. I want to download the table every time the button is pressed and new rows are added. Every time the button is pressed, it calls a function "foo()", so I'm essentially calling the function without needing to press the button.
This is what I'm currently executing in the console:
async function run(){
// download 4 tables
for (var i = 1; i < 5; i++){
// download current table
download_table("table" + i + ".csv");
// fetch next table
await foo(i+1);
}
}
run();
What ends up happening is that I download the same table 4 times in a row, and then the table switches to the 4th page.
EDIT: Question is not the same as duplicate, as it is not affected by the values of the variable "i". Identical results occur even without the for loop, by hard-coding the values of i:1,2,3,4...