Skip to content

Instantly share code, notes, and snippets.

@pablocastelo
Last active May 1, 2017 17:08
Show Gist options
  • Save pablocastelo/c964df7252d12dbaf677403596a1800c to your computer and use it in GitHub Desktop.
Save pablocastelo/c964df7252d12dbaf677403596a1800c to your computer and use it in GitHub Desktop.
import pandas as pd
from requests import get
import os
import uuid
print('Reading list...')
df = pd.read_excel('list.xlsx')
f = df.to_dict(orient='records')
user_input = input("Enter a valid directory (leave blank to use this location): ")
if user_input != '':
base_dir = user_input
else:
os.system("mkdir placas/")
base_dir = 'placas/'
print('Starting to fetch files...')
for x in f[:100]:
ff = "{}{}/".format(base_dir, x['placa'])
os.system("mkdir {}".format(ff))
with open("{}{}.{}".format(ff,x['link'][51:63], x['link'][64:67]), "wb") as file:
response = get(x['link'])
file.write(response.content)
print('Finished.')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment