import pycomm,os,lxml import mcollect class Resolver(object): def __init__(self): pass def zaopan(self,data): print(mcollect.getMongo()) re=self.mixbodyv(data,'zaopan') return re def today(self,data): re=self.mixbodyv(data,'today') return re def mixbodyv(self,data,fname): cpath=os.path.dirname(os.path.abspath(__file__)) val=pycomm.readFile(cpath+'/tmpl/zaopan.tmpl') data=str(data.decode('utf-8')) doc = lxml.etree.HTML(data) # doc=lxml.etree.fromstring(data) ls=doc.xpath('/html/head/script[2]/text()') text=ls[0] ftext=pycomm.parseTag(val,'CONTENT',text) ftext=str(ftext.encode('utf-8').decode('utf-8')) pycomm.saveFile(cpath+'/fcache/hg0088.'+fname+'.js',ftext) re=pycomm.exejs('node '+cpath+'/fcache/hg0088.'+fname+'.js') return re