designer_gen.py 1.6 KB

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