# Path: mod/models/nic_cache.py
# class NicCache(Base):
#     __tablename__ = 'nic'
#     cardnum = Column(Integer, primary_key=True)
#     text = Column(String(1024))
#     date = Column(Integer, nullable=False)


from config import *
from tornado.httpclient import HTTPRequest, AsyncHTTPClient, HTTPClient
from bs4 import BeautifulSoup
from ..models.nic_cache import NicCache
from sqlalchemy.orm.exc import NoResultFound
from time import time
import tornado.web
import tornado.gen
import urllib, re
import json, base64
                request = HTTPRequest(
                    DETIAL_URL,
                    method='GET',
                    headers={'Cookie':cookie},
                    request_timeout=TIME_OUT)
                response = client2.fetch(request)
                if len(response.body) > 10000:
                    soup = BeautifulSoup(response.body)
                    td = soup.findAll('td', {'bgcolor': '#FFFFFF', 'align': re.compile('center|right')})
                    if td[1].text[:-14]:
                        ret['b'] = {'state': td[0].text, 'used': td[1].text[:-14]+'B'}
                    else:
                        ret['b'] = {'state': td[0].text, 'used': td[2].text[:-14]+'B'}
                else:
                    ret['b'] = {'state':'未开通'.decode('utf-8'), 'used':'0 B'}

                self.chose_type(client2, cookie, 'web')
                request = HTTPRequest(
                    WEB_URL,
                    method='GET',
                    headers={'Cookie':cookie},
                    request_timeout=TIME_OUT)
                response = client2.fetch(request)
                if len(response.body) > 10000:
                    soup = BeautifulSoup(response.body)
                    td = soup.findAll('td', {'bgcolor': '#FFFFFF', 'align': 'center'})
                    ret['web'] = {'state': td[0].text+','+td[1].text, 'used': td[-1].text}
                else:
                    ret['web'] = {'state':'未开通'.decode('utf-8'), 'used':'0 B'}


# Path: mod/models/nic_cache.py
# class NicCache(Base):
#     __tablename__ = 'nic'
#     cardnum = Column(Integer, primary_key=True)
#     text = Column(String(1024))
#     date = Column(Integer, nullable=False)


# Path: mod/nic/handler.py
from config import *
from tornado.httpclient import HTTPRequest, AsyncHTTPClient, HTTPClient
from bs4 import BeautifulSoup
from ..models.nic_cache import NicCache
from sqlalchemy.orm.exc import NoResultFound
from time import time
import tornado.web
import tornado.gen
import urllib, re
import json, base64

                request = HTTPRequest(
                    DETIAL_URL,
                    method='GET',
                    headers={'Cookie':cookie},
                    request_timeout=TIME_OUT)
                response = client2.fetch(request)
                if len(response.body) > 10000:
                    soup = BeautifulSoup(response.body)
                    td = soup.findAll('td', {'bgcolor': '#FFFFFF', 'align': re.compile('center|right')})
                    if td[1].text[:-14]:
                        ret['b'] = {'state': td[0].text, 'used': td[1].text[:-14]+'B'}
                    else:
                        ret['b'] = {'state': td[0].text, 'used': td[2].text[:-14]+'B'}
                else:
                    ret['b'] = {'state':'未开通'.decode('utf-8'), 'used':'0 B'}

                self.chose_type(client2, cookie, 'web')
                request = HTTPRequest(
                    WEB_URL,
                    method='GET',
                    headers={'Cookie':cookie},
                    request_timeout=TIME_OUT)
                response = client2.fetch(request)
                if len(response.body) > 10000:
                    soup = BeautifulSoup(response.body)
                    td = soup.findAll('td', {'bgcolor': '#FFFFFF', 'align': 'center'})
                    ret['web'] = {'state': td[0].text+','+td[1].text, 'used': td[-1].text}
                else:
                    ret['web'] = {'state':'未开通'.decode('utf-8'), 'used':'0 B'}


                request = HTTPRequest(