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

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

View File

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