# Path: mod/_config.py

# 
# Path: mod/models/jwc_cache.py
# class JWCCache(Base):
#     __tablename__ = 'jwc'
#     date = Column(Integer, primary_key=True)
#     text = Column(String(10240), nullable=False)


from .._config import jwcCacheTime
from BeautifulSoup import BeautifulSoup
from config import JWC_URL, TIME_OUT
from tornado.httpclient import HTTPRequest, HTTPClient
from ..models.jwc_cache import JWCCache
from sqlalchemy.orm.exc import NoResultFound
from time import time, localtime, strftime
import tornado.web
import tornado.gen
import json, base64
import urllib,traceback,os
            client = HTTPClient()
            request = HTTPRequest(JWC_URL, method='GET',headers=header,request_timeout=TIME_OUT)
            response = client.fetch(request)
            html = response.body
            soup = BeautifulSoup(html)
            items = soup.findAll('table', {'width':"100%"})
            info = {
                '最新动态': self.abstract(items[12:17],1), 
                '教务信息': self.abstract(items[34:34+7],0), 
                '学籍管理': self.abstract(items[45:45+7],0), 
                '实践教学': self.abstract(items[56:56+7],0), 
                '合作办学': self.abstract(items[67:67+4],0),
                }
            retjson = {'code':200, 'content':info}
        except:
            retjson['code'] = 400
            # print traceback.print_exc()
        return retjson

    def abstract(self, tag, x):
        abst = []
        for t in tag:
            if 1:
                if x:
                    abst.append({
                        'title': t.a.attrs[2][1],
                        'href': JWC_URL+t.a.attrs[0][1],
                        'date': t.div.text,
                        })
                else:

# Path: mod/_config.py

# 
# Path: mod/models/jwc_cache.py
# class JWCCache(Base):
#     __tablename__ = 'jwc'
#     date = Column(Integer, primary_key=True)
#     text = Column(String(10240), nullable=False)


# Path: mod/jwc/handler.py
from .._config import jwcCacheTime
from BeautifulSoup import BeautifulSoup
from config import JWC_URL, TIME_OUT
from tornado.httpclient import HTTPRequest, HTTPClient
from ..models.jwc_cache import JWCCache
from sqlalchemy.orm.exc import NoResultFound
from time import time, localtime, strftime
import tornado.web
import tornado.gen
import json, base64
import urllib,traceback,os

            client = HTTPClient()
            request = HTTPRequest(JWC_URL, method='GET',headers=header,request_timeout=TIME_OUT)
            response = client.fetch(request)
            html = response.body
            soup = BeautifulSoup(html)
            items = soup.findAll('table', {'width':"100%"})
            info = {
                '最新动态': self.abstract(items[12:17],1), 
                '教务信息': self.abstract(items[34:34+7],0), 
                '学籍管理': self.abstract(items[45:45+7],0), 
                '实践教学': self.abstract(items[56:56+7],0), 
                '合作办学': self.abstract(items[67:67+4],0),
                }
            retjson = {'code':200, 'content':info}
        except:
            retjson['code'] = 400
            # print traceback.print_exc()
        return retjson

    def abstract(self, tag, x):
        abst = []
        for t in tag:
            if 1:
                if x:
                    abst.append({
                        'title': t.a.attrs[2][1],
                        'href': JWC_URL+t.a.attrs[0][1],
                        'date': t.div.text,
                        })
                else:

                    abst.append({