designer_gen.py 1.0 KB

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