Exemplo n.º 1
0
def answer_test(answer_url):
    answer = Answer(answer_url)
    # 获取该答案回答的问题
    question = answer.get_question()
    # 获取该答案的作者
    author = answer.get_author()
    # 获取该答案获得的赞同数
    upvote = answer.get_upvote()
    # 获取改该答案所属问题被浏览次数
    visit_times = answer.get_visit_times()
    # 获取所有给该答案点赞的用户信息
    voters = answer.get_voters()
    # 把答案输出为txt文件
    answer.to_txt()
    # 把答案输出为markdown文件
    answer.to_md()

    print question
    # <zhihu.Question instance at 0x7f0b25d13f80>
    # 一个Question对象
    print question.get_title()  # 输出:现实可以有多美好?
    print author
    # <zhihu.User instance at 0x7f0b25425b90>
    # 一个User对象
    print voters  # <generator object get_voters at 0x7f32fbe55730>(代表所有该答案点赞的用户的生成器)
    print author.get_user_id()  # 输出:田浩
    print upvote  # 输出:9320
    print visit_times  # 输出: 改答案所属问题被浏览次数
Exemplo n.º 2
0
def answer_test(answer_url):
    answer = Answer(answer_url)
    # 获取该答案回答的问题
    question = answer.get_question()
    # 获取该答案的作者
    author = answer.get_author()
    # 获取该答案获得的赞同数
    upvote = answer.get_upvote()
    # 获取改该答案所属问题被浏览次数
    visit_times = answer.get_visit_times()
    # 获取所有给该答案点赞的用户信息
    voters = answer.get_voters()
    # 把答案输出为txt文件
    answer.to_txt()
    # 把答案输出为markdown文件
    answer.to_md()

    print question
    # <zhihu.Question instance at 0x7f0b25d13f80>
    # 一个Question对象
    print question.get_title()  # 输出:现实可以有多美好?
    print author
    # <zhihu.User instance at 0x7f0b25425b90>
    # 一个User对象
    print voters # <generator object get_voters at 0x7f32fbe55730>(代表所有该答案点赞的用户的生成器)
    print author.get_user_id()  # 输出:田浩
    print upvote  # 输出:9320
    print visit_times  # 输出: 改答案所属问题被浏览次数
Exemplo n.º 3
0
def answer_test(answer_url):
    answer = Answer(answer_url)
    # 获取该答案回答的问题
    question = answer.get_question()
    # 获取该答案的作者
    author = answer.get_author()
    # 获取该答案获得的赞同数
    upvote = answer.get_upvote()
    # 获取改该答案所属问题被浏览次数
    visit_times = answer.get_visit_times()
    # 获取所有给该答案点赞的用户信息
    voters = answer.get_voters()
    # 获取答案长度
    answer_length = answer.get_answer_length()
    # 把答案输出为txt文件
    answer.to_txt()
    # 把答案输出为markdown文件
    answer.to_md()

    print question
    # <zhihu.Question instance at 0x7f0b25d13f80>
    # 一个Question对象
    print question.get_title()  # 输出:现实可以有多美好?
    print author
    # <zhihu.User instance at 0x7f0b25425b90>
    # 一个User对象
    for voter in voters:
        print voter
        # 一个 User 对象
    print author.get_user_id()  # 输出:田浩
    print upvote  # 输出:9320
    print visit_times  # 输出: 改答案所属问题被浏览次数
    print 'answer_length', answer_length  # 输出:
Exemplo n.º 4
0
def answer_test(answer_url):

    answer = Answer(answer_url)
    # 获取该答案回答的问题
    question = answer.get_question()
    # 获取该答案的作者
    author = answer.get_author()
    # 获取该答案获得的赞同数
    upvote = answer.get_upvote()
    # 把答案输出为txt文件
    answer.to_txt()
    # 把答案输出为markdown文件
    answer.to_md()

    print question 
    # <zhihu.Question instance at 0x7f0b25d13f80>
    # 一个Question对象
    print question.get_title() # 输出:现实可以有多美好?
    print author 
    # <zhihu.User instance at 0x7f0b25425b90>
    # 一个User对象
    print author.get_user_id() # 输出:田浩
    print upvote # 输出:9320
Exemplo n.º 5
0
def answer_test(answer_url):

    answer = Answer(answer_url)
    # 获取该答案回答的问题
    question = answer.get_question()
    # 获取该答案的作者
    author = answer.get_author()
    # 获取该答案获得的赞同数
    upvote = answer.get_upvote()
    # 把答案输出为txt文件
    answer.to_txt()
    # 把答案输出为markdown文件
    answer.to_md()

    print question
    # <zhihu.Question instance at 0x7f0b25d13f80>
    # 一个Question对象
    print question.get_title()  # 输出:现实可以有多美好?
    print author
    # <zhihu.User instance at 0x7f0b25425b90>
    # 一个User对象
    print author.get_user_id()  # 输出:田浩
    print upvote  # 输出:9320
Exemplo n.º 6
0
# -*- coding: utf-8 -*-
from zhihu import Answer

answer_url = "http://www.zhihu.com/question/24269892/answer/29960616"
answer = Answer(answer_url)
# 获取该答案回答的问题
question = answer.get_question()
# 获取该答案的作者
author = answer.get_author()
# 获取该答案获得的赞同数
upvote = answer.get_upvote()
# 获取该答案所属问题被浏览次数
visit_times = answer.get_visit_times()
# 获取所有给该答案点赞的用户信息
voters = answer.get_voters()
# 把答案输出为txt文件
answer.to_txt()
# 把答案输出为markdown文件
answer.to_md()

print question
# <zhihu.Question instance at 0x7f0b25d13f80>
# 一个Question对象
print question.get_title()  # 输出:现实可以有多美好?
print author
# <zhihu.User instance at 0x7f0b25425b90>
# 一个User对象
print voters
# <generator object get_voters at 0x7f32fbe55730>
# 代表所有该答案点赞的用户的生成器
print author.get_user_id()  # 输出:田浩