def logs(self):
        """获取收藏夹日志

        :return: 收藏夹日志中的操作，返回生成器
        :rtype: CollectActivity.Iterable
        """
        import time
        from datetime import datetime
        from .answer import Answer
        from .question import Question
        from .acttype import CollectActType

        self._make_soup()
        gotten_feed_num = 20
        offset = 0
        data = {
            'start': 0,
            '_xsrf': self.xsrf
        }
        api_url = self.url + 'log'
        while gotten_feed_num == 20:
            data['offset'] = offset
            res = self._session.post(url=api_url, data=data)
            gotten_feed_num = res.json()['msg'][0]
            soup = BeautifulSoup(res.json()['msg'][1])
            offset += gotten_feed_num
            zm_items = soup.find_all('div', class_='zm-item')

            for zm_item in zm_items:
                act_time = datetime.strptime(zm_item.find('time').text, "%Y-%m-%d %H:%M:%S")
                if zm_item.find('ins'):
                    link = zm_item.find('ins').a
                    act_type = CollectActType.INSERT_ANSWER
                elif zm_item.find('del'):
                    link = zm_item.find('del').a
                    act_type = CollectActType.DELETE_ANSWER
                else:
                    continue
                try:
                    answer_url = Zhihu_URL + link['href']
                    question_url = re_a2q.match(answer_url).group(1)
                    question = Question(question_url, link.text)
                    answer = Answer(
                        answer_url, question, session=self._session)
                    yield CollectActivity(
                        act_type, act_time, self.owner, self, answer)
                except AttributeError:
                    act_type = CollectActType.CREATE_COLLECTION
                    yield CollectActivity(
                        act_type, act_time, self.owner, self)
            data['start'] = zm_items[-1]['id'][8:]
            time.sleep(0.5)
def logs ( self ) : import time from datetime import datetime from . answer import Answer from . question import Question from . acttype import CollectActType self . _make_soup ( ) gotten_feed_num = 20 offset = 0 data = { 'start' : 0 , '_xsrf' : self . xsrf } api_url = self . url + 'log' while gotten_feed_num == 20 : data [ 'offset' ] = offset res = self . _session . post ( url = api_url , data = data ) gotten_feed_num = res . json ( ) [ 'msg' ] [ 0 ] soup = BeautifulSoup ( res . json ( ) [ 'msg' ] [ 1 ] ) offset += gotten_feed_num zm_items = soup . find_all ( 'div' , class_ = 'zm-item' ) for zm_item in zm_items : act_time = datetime . strptime ( zm_item . find ( 'time' ) . text , "%Y-%m-%d %H:%M:%S" ) if zm_item . find ( 'ins' ) : link = zm_item . find ( 'ins' ) . a act_type = CollectActType . INSERT_ANSWER elif zm_item . find ( 'del' ) : link = zm_item . find ( 'del' ) . a act_type = CollectActType . DELETE_ANSWER else : continue try : answer_url = Zhihu_URL + link [ 'href' ] question_url = re_a2q . match ( answer_url ) . group ( 1 ) question = Question ( question_url , link . text ) answer = Answer ( answer_url , question , session = self . _session ) yield CollectActivity ( act_type , act_time , self . owner , self , answer ) except AttributeError : act_type = CollectActType . CREATE_COLLECTION yield CollectActivity ( act_type , act_time , self . owner , self ) data [ 'start' ] = zm_items [ - 1 ] [ 'id' ] [ 8 : ] time . sleep ( 0.5 )
获取收藏夹日志

        :return: 收藏夹日志中的操作，返回生成器
        :rtype: CollectActivity.Iterable