designer_gen.py 877 B

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/python3
  2. import os
  3. import codecs
  4. import dataset
  5. def proc_file(fname):
  6. fr=codecs.open(fname,'r','utf-8')
  7. lines=fr.readlines()
  8. print(lines)
  9. fr.close()
  10. db = dataset.connect('mysql://hhh7796hhh:lYmWsu^ujcA1@hhh-v57-cluster.cluster-cmab1ctkglka.ap-northeast-2.rds.amazonaws.com:3306/xoops?charset=utf8mb4')
  11. dir_prefix='/var/www/jared-six/'
  12. cursor=db.query('SELECT hdesigner_id FROM xoops._hdesigner where onoff=1; ')
  13. for c in cursor:
  14. did=c['hdesigner_id']
  15. print(did)
  16. curdir=dir_prefix+str(did)
  17. if not os.path.exists(curdir):
  18. os.mkdir(curdir)
  19. os.chdir(curdir)
  20. os.system('curl https://hhh.com.tw/designers/cases/'+str(did)+'/1-page/new-sort/ -o index.html')
  21. proc_file(curdir+"/index.html")
  22. break
  23. #for l in lst:
  24. # os.chdir(curdir)
  25. # os.system('curl https://hhh.com.tw/columns/detail/'+l+'/ > index.html')