Skip to content

Instantly share code, notes, and snippets.

@sayakpaul
Created January 17, 2023 13:46
Show Gist options
  • Save sayakpaul/cada598d8321a5f6cb8cc16fe736ae07 to your computer and use it in GitHub Desktop.
Save sayakpaul/cada598d8321a5f6cb8cc16fe736ae07 to your computer and use it in GitHub Desktop.
"""
Referred from https://stackoverflow.com/questions/534839/how-to-create-a-guid-uuid-in-python
"""
import os
import uuid
from concurrent.futures import ThreadPoolExecutor
import pandas as pd
import requests
def download(url, path):
response = requests.get(url)
with open(path, "wb") as handle:
handle.write(response.content)
df = pd.read_csv("path_to_aesthetics_6plus_8k.csv")
urls = df["URL"].values.tolist()
paths = []
for _ in urls:
hex = uuid.uuid4().hex
paths.append(f"{hex}.jpg")
with ThreadPoolExecutor(max_workers=8) as executor:
executor.map(download, urls, paths)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment