From 35ee9664f4f9e6e0ed3f5e867f2bcf3708a912d6 Mon Sep 17 00:00:00 2001 From: mozillazg Date: Mon, 12 Jan 2015 21:26:04 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix=20=E6=97=A0=E6=B3=95=E5=8F=91=E9=80=81?= =?UTF-8?q?=E7=9F=AD=E4=BF=A1=E5=92=8C=E8=B8=A2=E4=BA=BA=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=8Cfixes=20#4,=20fixes=20#5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shanbay/team.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/shanbay/team.py b/shanbay/team.py index 1a5720a..4166371 100644 --- a/shanbay/team.py +++ b/shanbay/team.py @@ -173,8 +173,10 @@ def get_tag_string(html, class_, tag='td', n=0): for member_html in members_html.find_all('tr', class_='member'): _id = member_html.attrs['data-id'] try: - username = member_html.find_all('td', class_='user' - )[0].find('img').attrs['alt'] + user_url = member_html.find_all('td', class_='user' + )[0].find('a').attrs['href'] + username = self.get_username('http://www.shanbay.com' + + user_url) except Exception as e: logger.exception(e) username = '' @@ -217,6 +219,12 @@ def get_tag_string(html, class_, tag='td', n=0): members.append(member) return members + def get_username(self, url): + html = self.request(url).text + soup = BeautifulSoup(html) + t = soup.find_all(class_='page-header')[0].find_all('h2')[0].text.strip() + return t.strip(u'的日记').strip() + def dismiss(self, member_ids): """踢人. 注意别把自己给踢了. @@ -225,7 +233,7 @@ def dismiss(self, member_ids): """ url = 'http://www.shanbay.com/api/v1/team/member/' data = { - 'action': 'dismiss', + 'action': 'dispel', } if isinstance(member_ids, (list, tuple)): data['ids'] = ','.join(map(str, member_ids)) From 6789dd9e6d762acb5e3ded794d1dd4341de0cea2 Mon Sep 17 00:00:00 2001 From: mozillazg Date: Mon, 12 Jan 2015 21:41:35 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=A0=B9=E6=8D=AE=20response=20=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E5=88=A4=E6=96=AD=E8=B8=A2=E4=BA=BA=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E6=88=90=E5=8A=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shanbay/team.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/shanbay/team.py b/shanbay/team.py index 4166371..b1a325a 100644 --- a/shanbay/team.py +++ b/shanbay/team.py @@ -239,7 +239,12 @@ def dismiss(self, member_ids): data['ids'] = ','.join(map(str, member_ids)) else: data['ids'] = member_ids - return self.request(url, 'put', data=data).ok + r = self.request(url, 'put', data=data) + try: + return r.json()['msg'] == "SUCCESS" + except Exception as e: + logger.exception(e) + return False def forum_id(self): """小组发帖要用的 forum_id""" From 736b5621119771cf3e331905e59871469347143f Mon Sep 17 00:00:00 2001 From: mozillazg Date: Tue, 13 Jan 2015 07:48:48 +0800 Subject: [PATCH 3/3] v0.3.3 --- CHANGELOG.rst | 5 +++++ shanbay/__init__.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 7494152..1b8035d 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,11 @@ Changelog ========= +0.3.3 (2015-01-13) +------------------ +- 修复扇贝改版导致"无法获取组员用户名导致发送短信失败"的问题 +- 修复扇贝改版导致"无法成功踢人"的问题 + 0.3.2 (2014-08-22) ------------------ - 小组管理页面改版 diff --git a/shanbay/__init__.py b/shanbay/__init__.py index 4c46ca4..dd83126 100644 --- a/shanbay/__init__.py +++ b/shanbay/__init__.py @@ -6,7 +6,7 @@ """Python API for shanbay.com""" __title__ = 'shanbay' -__version__ = '0.3.2' +__version__ = '0.3.3' __author__ = 'mozillazg' __email__ = 'mozillazg101@gmail.com' __license__ = 'MIT'