Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python urllib.request.urlretrieve with a progressbar

import progressbar

class MyProgressBar():
    def __init__(self):
        self.pbar = None

    def __call__(self, block_num, block_size, total_size):
        if not self.pbar:
            self.pbar=progressbar.ProgressBar(maxval=total_size)
            self.pbar.start()

        downloaded = block_num * block_size
        if downloaded < total_size:
            self.pbar.update(downloaded)
        else:
            self.pbar.finish()

# call :
urllib.request.urlretrieve('img_url', 'img_filename', MyProgressBar())
Comment

PREVIOUS NEXT
Code Example
Python :: convert a python object and store it in a JSON file in the local system 
Python :: Solve abstract model relations conflicts while using inheritance 
Python :: !value in python 
Python :: how to click the next button on a website using python 
Python :: pandas within group pairwise distances 
Python :: pyqt grid layout 
Python :: # check built-in function using dir() 
Python :: Find number of triangles that can be made by given sides of triangle 
Python :: # print random number 
Python :: list cwd python 
Python :: load shapefile fiona multiline intersection 
Python :: load xgb 
Python :: to create an array with values that are spaced linearly in a specified interval 
Python :: python get currentmonth 
Python :: Find Factors of a Number using While Loop with validation 
Python :: Handling errors while using os.makedirs() method 
Python :: display csv data into flask api 
Python :: scikit learn lazy predict 
Python :: python set vs tuple performance 
Python :: python sqlite select where 
Python :: Annotation graphique python 
Python :: Algorithm of Broadcasting with NumPy Arrays 
Python :: how to shuffle list in djnago 
Python :: Python NumPy asanyarray Function Example Tuple to an array 
Python :: First CGI program 
Python :: assignment 8.4 python data structures 
Python :: modles en django 
Python :: check if string is palindrome using recursion in python 
Python :: should either include a `queryset` attribute, 
Python :: gensim prepare corpus 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =