diff --git a/ybqt.py b/ybqt.py index 493f1f1..2b40a92 100755 --- a/ybqt.py +++ b/ybqt.py @@ -129,16 +129,17 @@ def runVote(self): self.pro = self.pro + self.prog self.prosig.emit(self.pro) self.wait() - + voteget = [] for i in range(0, int(self.vote_control_count)): try: - self.vote_id = ybvote.vote( + votevote = ybvote.vote( self.token, self.puid, self.group_id - ).get( - self.vote_control_count - )["data"]["list"][i]["id"] + ) + if not voteget: + voteget = votevote.get(self.vote_control_count) + self.vote_id = voteget[i]["id"] votego = ybvote.go( self.token, self.puid, @@ -216,6 +217,7 @@ def runTopic(self): self.pro = self.pro + self.prog self.prosig.emit(self.pro) self.wait() + topicget = [] for i in range(0, int(self.topic_control_count)): try: topicgo = ybtopic.topic( @@ -224,8 +226,9 @@ def runTopic(self): self.group_id, self.channel_id ) - self.article_id = topicgo.get(self.topic_control_count)[ - "data"]["list"][i]["id"] + if not topicget: + topicget = topicgo.get(size=self.topic_control_count) + self.article_id = topicget[i]["id"] if self.topic_up: try: response = topicgo.up(self.article_id) diff --git a/ybtopic.py b/ybtopic.py index 9d8b171..e96f673 100755 --- a/ybtopic.py +++ b/ybtopic.py @@ -36,23 +36,25 @@ def add(self, title, content): 获取话题 <- 正则 ''' - def get(self, size=0, Sections_id=-1, need_notice=0, my=0): - - payload = { - 'channel_id': self.channel_id, - 'puid': self.puid, - 'group_id': self.group_id, - 'page': 0, - 'size': size, - 'orderby': 'updateTime', - 'Sections_id': Sections_id, - 'need_notice': need_notice, - 'my': my - } - - Get_Topic = r.post(BASEURL + 'forum/article/listAjax', - cookies=self.token, data=payload, timeout=10) - return Get_Topic.json() + def get(self, size=0, page=0, Sections_id=-1, need_notice=0, my=0): + tmp = [] + for i in range(1, size//10 + 1): # Extend json list to control size + payload = { + 'channel_id': self.channel_id, + 'puid': self.puid, + 'group_id': self.group_id, + 'page': i, # Should be 0 originally, work as disable page parse + 'size': 10, # Stick to 10 by stupid dev working yiban + 'orderby': 'updateTime', + 'Sections_id': Sections_id, + 'need_notice': need_notice, + 'my': my + } + + Get_Topic = r.post(BASEURL + 'forum/article/listAjax', + cookies=self.token, data=payload, timeout=10) + tmp.extend(Get_Topic.json()["data"]["list"]) + return tmp # Return larger list, the overflowing lists could be droped by function. ''' 获取评论 diff --git a/ybvote.py b/ybvote.py index 34f190c..b4480f3 100755 --- a/ybvote.py +++ b/ybvote.py @@ -69,7 +69,7 @@ def get(self, size=10, page=0, status=1, sort=1, time=0): Get_Vote = r.post(BASEURL + 'vote/index/getVoteList', cookies=self.token, data=payload, timeout=10) - return Get_Vote.json() + return Get_Vote.json()["data"]["list"] class go: