Commit bc3d1399 authored by Mario Chirinos's avatar Mario Chirinos

last date finder

parent 9518b445
...@@ -40,7 +40,6 @@ def crawlNews(directory, cfg, endDate=datetime.datetime.now()): ...@@ -40,7 +40,6 @@ def crawlNews(directory, cfg, endDate=datetime.datetime.now()):
''' '''
startDate = findLastDate(directory) startDate = findLastDate(directory)
# endDate = datetime.datetime.now()
if startDate is None: if startDate is None:
startDate=datetime.datetime.strptime(cfg["startDate"], '%Y-%m-%d') startDate=datetime.datetime.strptime(cfg["startDate"], '%Y-%m-%d')
print("start: ", startDate, "end: ", endDate) print("start: ", startDate, "end: ", endDate)
...@@ -49,13 +48,10 @@ def crawlNews(directory, cfg, endDate=datetime.datetime.now()): ...@@ -49,13 +48,10 @@ def crawlNews(directory, cfg, endDate=datetime.datetime.now()):
for i in range(delta.days + 1): for i in range(delta.days + 1):
day = startDate + datetime.timedelta(days=i) day = startDate + datetime.timedelta(days=i)
yeardir = directory+str(day.year)+"/" yeardir = directory+str(day.year)+"/"
if not os.path.exists(yeardir): if not os.path.exists(yeardir):
os.mkdir(yeardir) os.mkdir(yeardir)
print("dir: ", yeardir)
print(day) print(day)
print("CWD:", os.getcwd())
# return
print("scrapy crawl noticias --nolog -O "+yeardir+day.strftime('%Y-%m-%d')+".json -a year="+str(day.year)+" -a month="+str(day.month)+" -a day="+str(day.day)+"") print("scrapy crawl noticias --nolog -O "+yeardir+day.strftime('%Y-%m-%d')+".json -a year="+str(day.year)+" -a month="+str(day.month)+" -a day="+str(day.day)+"")
#=============================================================================== #===============================================================================
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment