Skip to main content

Command Palette

Search for a command to run...

3 ways to download file in Python

Updated
1 min read
M

Mohamad's interest is in Programming (Mobile, Web, Database and Machine Learning). He is studying at the Center For Artificial Intelligence Technology (CAIT), Universiti Kebangsaan Malaysia (UKM).

[1] Using requests

import requests
URL = "https://archive.org/download/embeddingmodel/GoogleNews-vectors-negative300.bin.gz"
response = requests.get(URL)
open(URL.split('/')[-1], "wb").write(response.content)

[2] Using wget

pip install wget

URL = "https://archive.org/download/embeddingmodel/GoogleNews-vectors-negative300.bin.gz"
response = wget.download(URL,URL.split('/')[-1])

[3] Using urllib

pip install urllib

from urllib import request
URL = "https://archive.org/download/embeddingmodel/GoogleNews-vectors-negative300.bin.gz"
response = request.urlretrieve(URL,URL.split('/')[-1])
3 ways to download file in Python