Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- import sys
- import requests
- def downloadWithProgressBar(link, file_name):
- with open(file_name, "wb") as f:
- print "\nDownloading %s" % file_name
- response = requests.get(link, stream=True)
- total_length = response.headers.get('content-length')
- if total_length is None: # no content length header
- f.write(response.content)
- else:
- dl = 0
- total_length = int(total_length)
- for data in response.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-done)) )
- sys.stdout.flush()
- file = open("psmpkg.csv")
- data = file.read()
- urls = re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', data.replace(",MISSING,",""))
- count = 0
- while count != len(urls):
- downloadWithProgressBar(urls[count],str(count)+".pkg")
- count += 1
Add Comment
Please, Sign In to add comment