Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

save image requests python

import requests

url = 'http://google.com/favicon.ico'
r = requests.get(url, allow_redirects=True)
open('google.ico', 'wb').write(r.content)
Comment

save images with requests python

import requests # request img from web
import shutil # save img locally

url = input('Please enter an image URL (string):') #prompt user for img url
file_name = input('Save image as (string):') #prompt user for file_name

res = requests.get(url, stream = True)

if res.status_code == 200:
    with open(file_name,'wb') as f:
        shutil.copyfileobj(res.raw, f)
    print('Image sucessfully Downloaded: ',file_name)
else:
    print('Image Couldn't be retrieved')
Comment

PREVIOUS NEXT
Code Example
Python :: how to import image in python 
Python :: how to save a dictionary to excel in python 
Python :: extract ints from strings in Pandas 
Python :: yield godot 
Python :: flask if statement 
Python :: tkinter load image 
Python :: How to convert an integer number into words in python? 
Python :: how to locate image using pyautogui 
Python :: python run 2 functions at the same time 
Python :: python utf 8 encoding 
Python :: genspider scrapy 
Python :: get time taken to execute python script 
Python :: python dictionary remove nonetype 
Python :: generate random string python 
Python :: python print in color 
Python :: dataframe select entries that are in a list 
Python :: dollar 
Python :: matplotlib grid in background 
Python :: display selective fields in admin page django 
Python :: order pandas dataframe by column values 
Python :: exclude columns pandas 
Python :: how to get distinct value in a column dataframe in python 
Python :: how to do pandas profiling 
Python :: python import json into pymongo 
Python :: turn pandas entries into strings 
Python :: api xml response to json python 
Python :: center buttons tkinter 
Python :: scikit learn r2 score 
Python :: how to blit text in pygame 
Python :: flask development mode 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =