Ejemplo n.º 1
0
    def __search_book_html(self, anywords, page):
        """
        检索图书列表页面
        :param anywords: 关键字
        :param page:  页码
        :return: html code
        """
        _params = {
            "dt": "ALL",
            "cl": "ALL",
            "dp": "20",
            "sf": "M_PUB_YEAR",
            "ob": "DESC",
            "sm": "table",
            "dept": "ALL",
            "ecx": "0",
            "anywords": "",  # not anywords..
            "page": 1,
        }

        _headers = {
            "Host": "lib.wyu.edu.cn",
            "Referer": "http://lib.wyu.edu.cn/opac/search.aspx",
            "Accept-Language": ":zh-CN,zh;q=0.8,en;q=0.6,zh-TW;q=0.4",
        }

        # url要对中文编码..
        _params["anywords"] = anywords.decode("utf-8").encode("gbk")
        _params["page"] = page
        r = requests.get(url=WyuLibrary.url_search, headers=_headers, params=_params, timeout=self._timeout)
        # _.d(r.content.decode(_.get_charset(r.content)))
        return r.content.decode(_.get_charset(r.content))
Ejemplo n.º 2
0
 def __get_score_html(self):
     self._headers['Referer'] = 'http://jwc.wyu.edu.cn/student/menu.asp'
     r = requests.get('http://jwc.wyu.edu.cn/student/f4_myscore11.asp',
                      headers=self._headers,
                      allow_redirects=False,
                      cookies=self._cookies)
     return r.content.decode(_.get_charset(r.content))
Ejemplo n.º 3
0
    def __search_book_html(self, anywords, page):
        """
        检索图书列表页面
        :param anywords: 关键字
        :param page:  页码
        :return: html code
        """
        _params = {
            'dt': 'ALL',
            'cl': 'ALL',
            'dp': '20',
            'sf': 'M_PUB_YEAR',
            'ob': 'DESC',
            'sm': 'table',
            'dept': 'ALL',
            'ecx': '0',
            'anywords': '',  # not anywords..
            'page': 1
        }

        _headers = {
            'Host': 'lib.wyu.edu.cn',
            'Referer': 'http://lib.wyu.edu.cn/opac/search.aspx',
            'Accept-Language': ':zh-CN,zh;q=0.8,en;q=0.6,zh-TW;q=0.4'
        }

        # url要对中文编码..
        _params['anywords'] = anywords.decode('utf-8').encode('gbk')
        _params['page'] = page
        r = requests.get(url=WyuLibrary.url_search,
                         headers=_headers,
                         params=_params,
                         timeout=self._timeout)
        # _.d(r.content.decode(_.get_charset(r.content)))
        return r.content.decode(_.get_charset(r.content))
Ejemplo n.º 4
0
 def __get_course_html(self):
     """
     获得课表页面
     :return: 已转码的html
     """
     self._headers['Referer'] = 'http://jwc.wyu.edu.cn/student/menu.asp'
     r = requests.get('http://jwc.wyu.edu.cn/student/f3.asp', headers=self._headers, cookies=self._cookies)
     return r.content.decode(_.get_charset(r.content))
Ejemplo n.º 5
0
 def __wyu_news_content(url):
     r = requests.get(url)
     encoding = _.get_charset(r.content)
     try:
         return r.content.decode(encoding)
     except Exception as e:
         # gb2312不行就换成gbk尝试
         if encoding != 'gbk':
             return r.content.decode('gbk')
         return r.content
Ejemplo n.º 6
0
 def __get_course_html(self):
     """
     获得课表页面
     :return: 已转码的html
     """
     self._headers['Referer'] = 'http://jwc.wyu.edu.cn/student/menu.asp'
     r = requests.get('http://jwc.wyu.edu.cn/student/f3.asp',
                      headers=self._headers,
                      cookies=self._cookies)
     return r.content.decode(_.get_charset(r.content))
Ejemplo n.º 7
0
    def _get_electricity_info_html( apart_id, meter_room):
        """get html

        :param apart_id: 栋数
        :param meter_room: 宿舍号
        """
        if apart.get(apart_id) is None:
            raise KeyError('not support the apart_id= ' + apart_id)
        post_data = {
            'action': 'search',
            'apartID': apart.get(apart_id),
            'meter_room': apart_id + meter_room
        }
        r = requests.post('http://202.192.252.140/index.asp', data=post_data)
        return r.content.decode(_.get_charset(r.content))
Ejemplo n.º 8
0
 def __book_status_html(self, ctrlno):
     """
     获取图书借阅页面
     :param ctrlno:
     :return:
     """
     _params = {"ctrlno": ctrlno}
     _headers = {
         "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
         "Accept-Encoding": "gzip, deflate, sdch",
         "Accept-Language": "zh-CN,zh;q=0.8,en;q=0.6,zh-TW;q=0.4",
         "Host": "lib.wyu.edu.cn",
         "Referer": "http://lib.wyu.edu.cn/opac/searchresult.aspx",
     }
     r = requests.get(url=WyuLibrary.url_book_info, headers=_headers, params=_params, timeout=self._timeout)
     # _.d(r.content.decode(_.get_charset(r.content)))
     return r.content.decode(_.get_charset(r.content))
Ejemplo n.º 9
0
 def __book_status_html(self, ctrlno):
     """
     获取图书借阅页面
     :param ctrlno:
     :return:
     """
     _params = {'ctrlno': ctrlno}
     _headers = {
         'Accept':
         'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
         'Accept-Encoding': 'gzip, deflate, sdch',
         'Accept-Language': 'zh-CN,zh;q=0.8,en;q=0.6,zh-TW;q=0.4',
         'Host': 'lib.wyu.edu.cn',
         'Referer': 'http://lib.wyu.edu.cn/opac/searchresult.aspx'
     }
     r = requests.get(url=WyuLibrary.url_book_info,
                      headers=_headers,
                      params=_params,
                      timeout=self._timeout)
     # _.d(r.content.decode(_.get_charset(r.content)))
     return r.content.decode(_.get_charset(r.content))
Ejemplo n.º 10
0
 def _get_stu_info(self):
     r = requests.get('http://jwc.wyu.edu.cn/student/f1.asp', headers=self._headers, cookies=self._cookies)
     print r.content.decode(_.get_charset(r.content))
Ejemplo n.º 11
0
 def __get_score_html(self):
     self._headers['Referer'] = 'http://jwc.wyu.edu.cn/student/menu.asp'
     r = requests.get('http://jwc.wyu.edu.cn/student/f4_myscore11.asp', headers=self._headers, allow_redirects=False,
                      cookies=self._cookies)
     return r.content.decode(_.get_charset(r.content))
Ejemplo n.º 12
0
 def __wyu_news(page):
     url = 'http://www.wyu.cn/news/default.asp'
     params = {'page': page}
     r = requests.get(url, params=params)
     encoding = _.get_charset(r.content)
     return r.content.decode(encoding)
Ejemplo n.º 13
0
 def _get_stu_info(self):
     r = requests.get('http://jwc.wyu.edu.cn/student/f1.asp',
                      headers=self._headers,
                      cookies=self._cookies)
     print r.content.decode(_.get_charset(r.content))