From 25dfd9bb3a8559a9b8c699e9542ce8da4e78dd32 Mon Sep 17 00:00:00 2001 From: Sitoi <133397418@qq.com> Date: Fri, 9 Apr 2021 19:19:23 +0800 Subject: [PATCH] =?UTF-8?q?:hammer:=20=E4=BF=AE=E5=A4=8D=20=E3=80=90?= =?UTF-8?q?=E7=99=BE=E5=BA=A6=E8=B4=B4=E5=90=A7=E3=80=91=E6=95=B0=E9=87=8F?= =?UTF-8?q?=E5=A4=AA=E5=A4=9A=E7=AD=BE=E5=88=B0=E5=A4=B1=E8=B4=A5=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 - LICENSE | 1 + rsa/__init__.py | 10 +++++----- tieba/tieba.py | 22 +++++----------------- 4 files changed, 11 insertions(+), 23 deletions(-) diff --git a/.gitignore b/.gitignore index 24e038e..296ee97 100644 --- a/.gitignore +++ b/.gitignore @@ -130,5 +130,4 @@ dmypy.json # Pyre type checker .pyre/ .idea -jingdong config.json \ No newline at end of file diff --git a/LICENSE b/LICENSE index a3705a4..9aad7b2 100644 --- a/LICENSE +++ b/LICENSE @@ -19,3 +19,4 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/rsa/__init__.py b/rsa/__init__.py index 1567dc1..1801dff 100644 --- a/rsa/__init__.py +++ b/rsa/__init__.py @@ -21,9 +21,9 @@ prevent repetitions, or other common security improvements. Use with care. """ -from rsa.key import newkeys, PrivateKey, PublicKey -from rsa.pkcs1 import encrypt, decrypt, sign, verify, DecryptionError, \ - VerificationError, find_signature_hash, sign_hash, compute_hash +from rsa.key import PrivateKey, PublicKey, newkeys +from rsa.pkcs1 import DecryptionError, VerificationError, compute_hash, decrypt, encrypt, find_signature_hash, sign, \ + sign_hash, verify __author__ = "Sybren Stuvel, Barry Mead and Yesudeep Mangalapilly" __date__ = '2020-06-12' @@ -36,5 +36,5 @@ if __name__ == "__main__": doctest.testmod() __all__ = ["newkeys", "encrypt", "decrypt", "sign", "verify", 'PublicKey', - 'PrivateKey', 'DecryptionError', 'VerificationError', - 'find_signature_hash', 'compute_hash', 'sign_hash'] + 'PrivateKey', 'DecryptionError', 'VerificationError', + 'find_signature_hash', 'compute_hash', 'sign_hash'] diff --git a/tieba/tieba.py b/tieba/tieba.py index 335c162..c6b404f 100644 --- a/tieba/tieba.py +++ b/tieba/tieba.py @@ -28,14 +28,6 @@ class TiebaCheckIn: user_name = self.login_info(session=session)["userName"] return tbs, user_name - @staticmethod - def tieba_list(session): - data = session.get(url="https://tieba.baidu.com/mo/q/newmoindex").json() - if data["no"] == 0: - return [x["forum_name"] for x in data["data"]["like_forum"]] - else: - return [] - @staticmethod def tieba_list_more(session): content = session.get(url="http://tieba.baidu.com/f/like/mylike?&pn=1", timeout=(5, 20)) @@ -50,18 +42,12 @@ class TiebaCheckIn: content = session.get(url=f"http://tieba.baidu.com/f/like/mylike?&pn={next_page}", timeout=(5, 20)) def get_tieba_list(self, session): - try: - session.get(url="https://tieba.baidu.com/f/user/json_userinfo", allow_redirects=False).json() - except Exception as e: - print(e) - tieba_list = self.tieba_list(session=session) - else: - tieba_list = self.tieba_list_more(session=session) + tieba_list = list(self.tieba_list_more(session=session)) return tieba_list @staticmethod def sign(session, tb_name_list, tbs): - success_count, error_count, exist_count = 0, 0, 0 + success_count, error_count, exist_count, shield_count = 0, 0, 0, 0 for tb_name in tb_name_list: md5 = hashlib.md5(f"kw={tb_name}tbs={tbs}tiebaclient!!!".encode("utf-8")).hexdigest() data = {"kw": tb_name, "tbs": tbs, "sign": md5} @@ -71,11 +57,13 @@ class TiebaCheckIn: success_count += 1 elif response["error_code"] == "160002": exist_count += 1 + elif response["error_code"] == "340006": + shield_count += 1 else: error_count += 1 except Exception as e: print(f"贴吧 {tb_name} 签到异常,原因{str(e)}") - msg = f"贴吧总数: {len(tb_name_list)}\n签到成功: {success_count}\n已经签到: {exist_count}\n签到失败: {error_count}" + msg = f"贴吧总数: {len(tb_name_list)}\n签到成功: {success_count}\n已经签到: {exist_count}\n被屏蔽的: {shield_count}\n签到失败: {error_count}" return msg def main(self):