# 資料夾，字典。

#coding=UTF-8
#!/usr/bin/python

from datetime import datetime
import os

# 字典，新聞分類。
newsDic = {
   'politics' : '政治',
   # 'blogs' : '論壇',
   'finance' : '財經',
   'entertainment' : '娛樂',
   'sports' : '運動',
   'society' : '社會地方',
   'world' : '國際',
   'lifestyle' : '生活',
   'health' : '健康',
   'technology' : '科技',
   }

def getYahooNews2(subject):
   today = "{:%Y%m%d}".format(datetime.today())
#   print(today)
   dir = os.path.dirname(__file__)
   path = os.path.join(dir, today)
   subDir = os.path.join(path, subject)
   print(subDir)
   if not os.path.isdir(subDir):
      os.mkdir(subDir)

def getYahooNews():
   today = "{:%Y%m%d}".format(datetime.today())
   dir = os.path.dirname(__file__)
   path = os.path.join(dir, today)
   if not os.path.isdir(path):
      os.mkdir(path)

   for d in newsDic:
      print(d, newsDic[d])
      getYahooNews2(d)

# 主程式 main
getYahooNews()
