How to download files in Python with progress bars

preview_player
Показать описание

I use Jupyter notebooks but it all works fine with VSCode and Terminal, PyCharm, etc!

Install the packages we talk about: pip install requests tqdm pandas

REMEMBER: If you're downloading text (CSV files, JSON, etc) you can use .write_text instead of .write_bytes

TRAGEDY: I think I need some synonyms for the word 'perfect'

====

CHAPTERS

00:00 Intro
01:41 The answers, right up front
03:01 Downloading files with urllib
06:48 Downloading files with requests
12:38 Using pathlib to get filenames
14:32 Reading in text files
19:04 Using tqdm for progress bars
21:42 Saving files into folders
25:40 Downloading files from CSVs
33:28 Saving CSVs as plain text files
35:17 Using wget instead of Python
38:16 Outro

====

THE GOOD METHOD

from pathlib import Path
import requests

output_dir = Path('downloaded')

for url in tqdm(urls):
print(url)

filename = Path(url).name


===

THE SHORTER, LESS FLEXIBLE METHOD

from os import path

for url in urls:

===

THE PANDAS TECHNIQUE

download_dir = Path('downloads')

def download_file(row):
url = row['url']
print("Downloading", url)

# filename = Path(url).name

Рекомендации по теме
Комментарии
Автор

thank you sir
that was very informative

sanketsan