I am developing a program in python to download a list of files. The are named as:
2012-01-01-01.html
2012-01-01-02.html
...
...
2012-12-30-99.html
The problem is I don't Know whether the file exists. So I have to check all the urls from 404
How can i make a generator that increments the counter for 'year'-'month'-'date'-'num
if one link fails then skip the date
and if all links of particular month fails skip month
and so on
I can only write code that is having lot of 'if's is there any better idea
wset_fail=[]
for year in [2012,2011]:
for month in range(1,12):
for day in range(1,31):
for num in range(1,100):
check = str(year)+'-'+str(month)+'-'+str(day)
if check not in wset_fail:
link = generate_name(year,month,day,num)
if link!='':
if download(link)==False:
wset_fail.append(str(year)+'-'+str(month)+'-'+str(day))
Its Working I am asking for some better solution