designer_gen.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. fw.write("function forum(){ \n")
  15. fw.write("var r8= document.getElementById('row_choz8'); \n")
  16. fw.write("var r9 = document.getElementById('row_choz9'); \n")
  17. fw.write(' r8.style.display="none"; \n')
  18. fw.write(' r9.style.display = "block"; \n')
  19. fw.write("} \n")
  20. #
  21. # print(lines)
  22. fr.close()
  23. fw.close()
  24. db = dataset.connect('mysql://hhh7796hhh:lYmWsu^ujcA1@hhh-v57-cluster.cluster-cmab1ctkglka.ap-northeast-2.rds.amazonaws.com:3306/xoops?charset=utf8mb4')
  25. dir_prefix='/var/www/jared-six/'
  26. cursor=db.query('SELECT hdesigner_id FROM xoops._hdesigner where onoff=1; ')
  27. for c in cursor:
  28. did=c['hdesigner_id']
  29. print(did)
  30. curdir=dir_prefix+str(did)
  31. if not os.path.exists(curdir):
  32. os.mkdir(curdir)
  33. os.chdir(curdir)
  34. os.system('curl https://hhh.com.tw/designers/cases/'+str(did)+'/1-page/new-sort/ -o orig.html')
  35. proc_file(curdir+"/orig.html",curdir+"/index.html")
  36. break
  37. #for l in lst:
  38. # os.chdir(curdir)
  39. # os.system('curl https://hhh.com.tw/columns/detail/'+l+'/ > index.html')