예제 #1
0
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()