12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- #!/usr/bin/python3
- import os
- import codecs
- import dataset
- def proc_file(fname,fname2):
- fr=codecs.open(fname,'r','utf-8')
- fw=codecs.open(fname2,'w','utf-8')
- lines=fr.readlines()
- for l in lines:
- if 'nav-link' in l and '設計師專欄' in l and 'class' in l:
- fw.write('<a class="nav-link " onclick="forum();">設計師專欄</a>')
- continue
- fw.write(l)
- if '</script>' in l:
- fw.write("\n")
- fw.write("function forum(){ \n")
- fw.write("var r8= document.getElementById('row_choz8'); \n")
- fw.write("var r9 = document.getElementById('row_choz9'); \n")
- fw.write(' r8.style.display="none"; \n')
- fw.write(' r9.style.display = "block"; \n')
- fw.write('alert("jared");')
- fw.write("} \n")
- #
- # print(lines)
- fr.close()
- fw.close()
- db = dataset.connect('mysql://hhh7796hhh:lYmWsu^ujcA1@hhh-v57-cluster.cluster-cmab1ctkglka.ap-northeast-2.rds.amazonaws.com:3306/xoops?charset=utf8mb4')
- dir_prefix='/var/www/jared-six/'
- cursor=db.query('SELECT hdesigner_id FROM xoops._hdesigner where onoff=1; ')
- for c in cursor:
- did=c['hdesigner_id']
- print(did)
- curdir=dir_prefix+str(did)
- if not os.path.exists(curdir):
- os.mkdir(curdir)
- os.chdir(curdir)
- os.system('curl https://hhh.com.tw/designers/cases/'+str(did)+'/1-page/new-sort/ -o orig.html')
- proc_file(curdir+"/orig.html",curdir+"/index.html")
- break
- #for l in lst:
- # os.chdir(curdir)
- # os.system('curl https://hhh.com.tw/columns/detail/'+l+'/ > index.html')
|