I’m writing a python program for downloading some pictures of students at my school.
Here is my code: `
import os
count = 0
max_c = 1000000
while max_c >= count:
os.system("curl http://www.tjoernegaard.dk/Faelles/ElevFotos/"+str(count)+".jpg > "+str(count)+".jpg")
count=count+1
`
The problem is that i only want so save the jpg if the image exists on the server (not 404), and since i don’t have all the image names on the server, i have to send a request for all images between 0 and 1000000, but not all images between 0 and 1000000 exists. So i only want so save the image if it exists on the server. How do i do this (ubuntu)?
Thank you in advance
should work, a 404 throws an exception