Monday 15 July 2013

Python progress bar and downloads -


I have a dragon script that launches a URL that is downloadable file. Is there any way to use the command line to download the python to oppose the browser launch?

Updated to your sample url:

To scrap a PDF, just a simple (slightly hacked) approach is written. Note that this works correctly only on Unix-based systems (Linux, Mac OS) because PowerShell "\ r"

  link = "http: // indy / abcde1245" file_name = F: Print "Downloading% s"% file_name response = requests.get (link, stream = true) total_length = response.headers.get ('content-length') if the file: "" (file_name, "wb"). Total_length None: # no content length header f.write (response.content) else: dl = 0 total_length = int (total_length) for data in feedback.iter_content (chunk_size = 4096): dl + = len (data) f .write (data) done = int (50 * dl / total_length) sys.stdout.write ("\ r [% s% s]"% ('=' * done, '' * (50-made))) Sys.stdout. Flush ()   

It uses it so that you can install it. This is similar to the following in your console:

& gt; Downloading DataData

& gt; [=============]

The progress bar script has a width of 52 characters (2 characters are only [] therefore 50 characters of progress). Represents 2% of each = download.

No comments:

Post a Comment