while I try to loop the 'urlpage' in sequential ascending trend, this only gives me the 0021 zip file and this file only after firefox asks me to download. What is wrong with my code and how can I make it loop to open all url from the serial numbers in my loop?
import urllib.request
from bs4 import BeautifulSoup
from selenium import webdriver
import time
import pandas as pd
import os
j=''
k=1
while k < 4:
j='002'+ str(k)
print(str(j))
if k>0:
urlpage = 'https://www150.statcan.gc.ca/n1/tbl/csv/3210'+j+'-eng.zip'
print(urlpage)
k+=1
# run firefox webdriver from executable path of your choice
driver = webdriver.Firefox()
# get web page
driver.get(urlpage)
# execute script to scroll down the page
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);var lenOfPage=document.body.scrollHeight;return lenOfPage;")
# sleep for 30s
time.sleep(30)
driver.quit()
0021
https://www150.statcan.gc.ca/n1/tbl/csv/32100021-eng.zip