Resolver.py 917 B

1234567891011121314151617181920212223242526272829
  1. import pycomm,os,lxml
  2. import mcollect
  3. class Resolver(object):
  4. def __init__(self):
  5. pass
  6. def zaopan(self,data):
  7. print(mcollect.getMongo())
  8. re=self.mixbodyv(data,'zaopan')
  9. return re
  10. def today(self,data):
  11. re=self.mixbodyv(data,'today')
  12. return re
  13. def mixbodyv(self,data,fname):
  14. cpath=os.path.dirname(os.path.abspath(__file__))
  15. val=pycomm.readFile(cpath+'/tmpl/zaopan.tmpl')
  16. data=str(data.decode('utf-8'))
  17. doc = lxml.etree.HTML(data)
  18. # doc=lxml.etree.fromstring(data)
  19. ls=doc.xpath('/html/head/script[2]/text()')
  20. text=ls[0]
  21. ftext=pycomm.parseTag(val,'CONTENT',text)
  22. ftext=str(ftext.encode('utf-8').decode('utf-8'))
  23. pycomm.saveFile(cpath+'/fcache/hg0088.'+fname+'.js',ftext)
  24. re=pycomm.exejs('node '+cpath+'/fcache/hg0088.'+fname+'.js')
  25. return re