#!/usr/bin/python3 import os import codecs import dataset db = dataset.connect('mysql://hhh7796hhh:lYmWsu^ujcA1@hhh-v57-cluster.cluster-cmab1ctkglka.ap-northeast-2.rds.amazonaws.com:3306/xoops?charset=utf8mb4') #lst=['5926','5878','5912','5939','5885','4300','1042','3559'] #lst=['3559'] #lst=['5926','5878','5912','5939','5885','4300','1042'] #lst=['5926','5878','5912','5939','5885','4300'] #lst=['5926'] ins_cmd='' dir_prefix='/var/www/jared-faq/' for l in lst: curdir=dir_prefix+l+'/index.html' outdir=dir_prefix+'modify/'+l+"/" # outfile='/tmp/out.html' if not os.path.exists(outdir): os.mkdir(outdir) outfile=outdir+'index.html' json_content=None cursor=db.query('select json_ld from xoops._hcolumn where hcolumn_id="'+l+'"') for c in cursor: json_content=c['json_ld'] break jsonld='' # curdir=dir_prefix+l+'/new.html' fr=codecs.open(curdir,'r','utf-8') lines=fr.readlines() fr.close() idx=0 alldata='' skipmode=False for line in lines: if '' in line: skipmode=False continue if skipmode: print('skip') continue if '