Last active
July 14, 2023 18:48
-
-
Save sk0x1234/77c5cfe53aaf455ca9ec120a11acfa09 to your computer and use it in GitHub Desktop.
script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import pathlib | |
with open("files.txt","r") as f: | |
urls = [ url.rstrip() for url in f.readlines()] | |
files_to_download = [] | |
for url in urls: | |
if ".zip" in url: | |
continue | |
else: | |
files_to_download.append(url) | |
def download(url) : | |
print(url) | |
req = requests.get(url,stream=True) | |
req.raise_for_status() | |
filename=pathlib.PurePosixPath(url).name | |
with open(filename, "wb" ) as f : | |
f.write(req.content) | |
# except requests.HTTPError.errno as err: | |
# print(err) | |
# exit(1) | |
if __name__ == "__main__" : | |
for url in files_to_download: | |
#print(files_to_download[:5]) | |
download(url) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment