Python Tools
Last updated on April 30, 2024 am
Download files from web(url)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| import requests import time from requests.auth import HTTPBasicAuth
def download(url,file_path): r = requests.get(url,auth=HTTPBasicAuth("id","keys")) with open(file_path, 'wb') as f: f.write(r.content) f.close() if __name__ == "__main__": url_base = "***" file_path_base = "***" for i in range(10863,12871): print(i) url = url_base + str(i) + ".webm" file_path = file_path_base + str(i) + ".webm" try: download(url,file_path) except: time.sleep(1) continue
|