Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhaoQi99 committed Dec 29, 2018
2 parents b1beb8c + 5523e7f commit b52bc89
Show file tree
Hide file tree
Showing 11 changed files with 701 additions and 6 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ SNNU-SDK 是陕西师范大学(SNNU)的一个第三方Python-SDK,实现了校
### 校园卡
- 校园卡消费明细
- 校园卡余额
- 校园卡照片

### 通知新闻
- 某部门的最新通知
- 某部门的最新新闻
- 所支持的部门

## 安装

Expand Down
6 changes: 6 additions & 0 deletions docs/source/changes.rst
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
Changelog
====================

Version 0.0.2
--------------

- 支持校园通知/新闻 :class:`snnusdk.Notice`, :class:`snnusdk.News`
- 支持校园卡个人照片 :class:`snnusdk.message.get_support_dep`
2 changes: 2 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ SNNU-SDK 是陕西师范大学(SNNU)的一个第三方Python-SDK,实现了校
libiary
room
campus
message
exceptions
changes

Expand All @@ -30,6 +31,7 @@ SNNU-SDK 是陕西师范大学(SNNU)的一个第三方Python-SDK,实现了校
libiary_example
room_example
campus_example
message_example

索引
==================
Expand Down
11 changes: 11 additions & 0 deletions docs/source/message.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
************
通知新闻接口
************

.. autoclass:: snnusdk.Notice
:members:

.. autoclass:: snnusdk.News
:members:

.. automethod:: snnusdk.message.get_support_dep
5 changes: 5 additions & 0 deletions docs/source/message_example.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
****************
通知新闻接口示例
****************

wait
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
EMAIL = '[email protected]'
AUTHOR = 'Qi Zhao'
REQUIRES_PYTHON = '>=3.0.0'
VERSION = '0.0.1'
VERSION = '0.0.2'

# What packages are required for this module to be executed?
REQUIRED = [
Expand Down
4 changes: 3 additions & 1 deletion snnusdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
from snnusdk.libiary import get_borrow_info
from snnusdk.urp import Urp
from snnusdk.room import Room
from snnusdk.campus import Campus
from snnusdk.campus import Campus
from snnusdk.message import Notice,News
from snnusdk.message import get_support_dep
41 changes: 37 additions & 4 deletions snnusdk/campus.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@
from requests.exceptions import ConnectionError

class Campus:
"""校园卡消费明细
"""校园卡相关信息
:param str id: 校园卡号
>>> c = Campus(id='2016xxx')
"""
url = 'http://edutech.snnu.edu.cn/ecard/ccc.asp'

class URLs:
CONSUMPTION= 'http://edutech.snnu.edu.cn/ecard/ccc.asp'
PHOTO='http://219.244.185.5:8228/getuserphoto.jsp?userid='

def __init__(self, id):
self.id = id
Expand Down Expand Up @@ -53,7 +56,7 @@ def get_list(self):
"""
ret = {}
try:
r = requests.post(self.url, data=self.data)
r = requests.post(self.URLs.CONSUMPTION, data=self.data)
r.encoding = 'utf-8'
soup = BeautifulSoup(r.text, 'lxml')
ls = table_to_list(
Expand Down Expand Up @@ -82,7 +85,37 @@ def __str__(self):
:return: 校园卡号
"""
return self.id

def get_photo(self):
"""获取个人照片
:rtype: dict
:return: 以二进制流的方式返回照片
>>> c = get_photo()
{
'msg': '获取成功',
'success': True,
'data': b'byte'
}
"""
ret = {}
try:
r=requests.get(self.URLs.PHOTO+self.id)
ret['msg']='获取成功'
ret['success'] = True
ret['data']=r.content
except ConnectionError:
ret['success'] = False
ret['msg']='网络连接失败'
ret['result'] = []
except Exception:
ret['success'] = False
ret['msg']='未知错误'
ret['result'] = None
finally:
return ret

if __name__ == "__main__":
a = Campus('201608735')
print(a.get_list())
print(a.get_photo())
Loading

0 comments on commit b52bc89

Please sign in to comment.