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
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)
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
def __init__(self): #threading.Thread.__init__(self) super(QuestionThread, self).__init__() self.client = ZhiHu()
def __init__(self): self.client = ZhiHu() pass
def getAnswer(q): zhihu = ZhiHu() a = zhihu.getAnswer(q) print a return a
# 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()