コード例 #1
0
ファイル: people_thread.py プロジェクト: wudizhangzhi/python
class People():
    def __init__(self):
        self.client = ZhiHu()
        pass

    def run(self):
        while True:
            r = redis_cache.spop('zhihu_url_people')
            if r:
                self.client.user(r)

                print '采集用户:%s' % r
            time.sleep(1)
        pass
コード例 #2
0
class QuestionThread(threading.Thread):
    def __init__(self):
        #threading.Thread.__init__(self)
        super(QuestionThread, self).__init__()
        self.client = ZhiHu()

    def run(self):
        print 'thread is start running'
        r = redis_cache.spop('zhihu_url_question')
        if r:
            self.client.question(r)

            print '采集问题:%s' % r
        else:
            print 'wait'
        time.sleep(1)
コード例 #3
0
class Question():
    def __init__(self):
        self.client = ZhiHu()
        pass

    def run(self):
        while True:
            r = redis_cache.spop('zhihu_url_question')
            if r:
                self.client.question(r)

                print '采集问题:%s' % r
            else:
                print 'wait'
            time.sleep(1)
        pass
コード例 #4
0
class QuestionThread(threading.Thread):
    def __init__(self):
        #threading.Thread.__init__(self)
        super(QuestionThread, self).__init__()
        self.client = ZhiHu()

    def run(self):
        print 'thread is start running'
        r = redis_cache.spop('zhihu_url_question')
        if r:
            self.client.question(r)

            print '采集问题:%s' % r
        else:
            print 'wait'
        time.sleep(1)
コード例 #5
0
class Question():
    def __init__(self):
        self.client = ZhiHu()
        pass

    def run(self):
        while True:
            r = redis_cache.spop('zhihu_url_question')
            if r:
                self.client.question(r)

                print '采集问题:%s' % r
            else:
                print 'wait'
            time.sleep(1)
        pass
コード例 #6
0
 def __init__(self):
     #threading.Thread.__init__(self)
     super(QuestionThread, self).__init__()
     self.client = ZhiHu()
コード例 #7
0
 def __init__(self):
     self.client = ZhiHu()
     pass
コード例 #8
0
 def __init__(self):
     #threading.Thread.__init__(self)
     super(QuestionThread, self).__init__()
     self.client = ZhiHu()
コード例 #9
0
 def __init__(self):
     self.client = ZhiHu()
     pass
コード例 #10
0
def getAnswer(q):
    zhihu = ZhiHu()
    a = zhihu.getAnswer(q)
    print a
    return a
コード例 #11
0
ファイル: example.py プロジェクト: PyBeaner/PyZhihu
# coding=utf-8

__author__ = 'PyBeaner'


from zhihu import ZhiHu

client = ZhiHu()
# t = client.get_topic('python')
# print(t)
# print(t.sub_topics)
# print(t.parent_topics)
# if t.follow():
#     print("followed topic:"+t.name)
# if t.unfollow():
#     print("unfollowed topic:"+t.name)

q = client.get_question('2015 NBA总决赛?')
print(q)
# print(q.answers)  # generator
# print(q.top_answer)
# for a in q.answers:
#     print(a)
for a in q.get_top_n_answers(3):
    print("-" * 40)
    print(a)
    print("评论列表(%d)" % a.comments_count)
    for c in a.get_latest_n_comments(5):
        print(c)
        # print(a.question)
        # q.follow()