Files
d4c-datapkg-statistical/experiments/scrape_statcan_tables/aria2c_download.ipynb
T

2.3 KiB

In [1]:
import time
import aria2p

# initialization, these are the default values
aria2 = aria2p.API(
    aria2p.Client(
        host="http://localhost",
        port=6800,
        secret=""
    )
)
In [2]:
# Helper function to wait for download to finish
def wait_for_download(download):
    print(f"Waiting for download: {download.name}")
    while download.is_active:
        print(f"Progress: {download.progress_string()} - {download.status}")
        time.sleep(10)
        download = aria2.get_download(download.gid)  # refresh state
    print(f"Download completed: {download.name} - Status: {download.status}")
    return download
In [ ]:
urls = ['https://data.dataforcanada.org/processed/statistics_canada/boundaries/2021/digital_boundary_files/db_2021.parquet']

download = aria2.add_uris(urls, options={"out": "test.parquet"})
download = wait_for_download(download)
Waiting for download: test.parquet
Progress: 0.00% - active
In [ ]: