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):