Skip to main content

Command Palette

Search for a command to run...

3 ways for Python to get Internet resources

Updated
1 min read
3 ways for Python to get Internet resources
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://instagram.com/favicon.ico"

response = requests.get(URL)

open("instagram.ico", "wb").write(response.content)

[2] Using wget

pip install wget

import wget

URL = "https://instagram.com/favicon.ico"

response = wget.download(URL, "instagram.ico")

[3] Using urllib

pip install urllib

from urllib import request

URL = "https://instagram.com/favicon.ico"

response = request.urlretrieve("https://instagram.com/favicon.ico", "instagram.ico")

source:

https://www.logilax.com/python-download-file-from-url/

6 views