🔨 修复 【百度贴吧】数量太多签到失败的问题

This commit is contained in:
Sitoi 2021-04-09 19:19:23 +08:00
parent 5757dc946c
commit 25dfd9bb3a
4 changed files with 11 additions and 23 deletions

1
.gitignore vendored
View File

@ -130,5 +130,4 @@ dmypy.json
# Pyre type checker # Pyre type checker
.pyre/ .pyre/
.idea .idea
jingdong
config.json config.json

View File

@ -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, 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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.

View File

@ -21,9 +21,9 @@ prevent repetitions, or other common security improvements. Use with care.
""" """
from rsa.key import newkeys, PrivateKey, PublicKey from rsa.key import PrivateKey, PublicKey, newkeys
from rsa.pkcs1 import encrypt, decrypt, sign, verify, DecryptionError, \ from rsa.pkcs1 import DecryptionError, VerificationError, compute_hash, decrypt, encrypt, find_signature_hash, sign, \
VerificationError, find_signature_hash, sign_hash, compute_hash sign_hash, verify
__author__ = "Sybren Stuvel, Barry Mead and Yesudeep Mangalapilly" __author__ = "Sybren Stuvel, Barry Mead and Yesudeep Mangalapilly"
__date__ = '2020-06-12' __date__ = '2020-06-12'

View File

@ -28,14 +28,6 @@ class TiebaCheckIn:
user_name = self.login_info(session=session)["userName"] user_name = self.login_info(session=session)["userName"]
return tbs, user_name 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 @staticmethod
def tieba_list_more(session): def tieba_list_more(session):
content = session.get(url="http://tieba.baidu.com/f/like/mylike?&pn=1", timeout=(5, 20)) 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)) content = session.get(url=f"http://tieba.baidu.com/f/like/mylike?&pn={next_page}", timeout=(5, 20))
def get_tieba_list(self, session): def get_tieba_list(self, session):
try: tieba_list = list(self.tieba_list_more(session=session))
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)
return tieba_list return tieba_list
@staticmethod @staticmethod
def sign(session, tb_name_list, tbs): 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: for tb_name in tb_name_list:
md5 = hashlib.md5(f"kw={tb_name}tbs={tbs}tiebaclient!!!".encode("utf-8")).hexdigest() md5 = hashlib.md5(f"kw={tb_name}tbs={tbs}tiebaclient!!!".encode("utf-8")).hexdigest()
data = {"kw": tb_name, "tbs": tbs, "sign": md5} data = {"kw": tb_name, "tbs": tbs, "sign": md5}
@ -71,11 +57,13 @@ class TiebaCheckIn:
success_count += 1 success_count += 1
elif response["error_code"] == "160002": elif response["error_code"] == "160002":
exist_count += 1 exist_count += 1
elif response["error_code"] == "340006":
shield_count += 1
else: else:
error_count += 1 error_count += 1
except Exception as e: except Exception as e:
print(f"贴吧 {tb_name} 签到异常,原因{str(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 return msg
def main(self): def main(self):