我正在使用StackAPI来获得投票最多的问题和这些问题的投票最多的答案:-
from stackapi import StackAPI
SITE = StackAPI('stackoverflow')
SITE.max_pages=1
SITE.page_size=10
questions = SITE.fetch('questions', min=20, tagged='python', sort='votes')
for quest in questions['items']:
if 'title' not in quest or quest['is_answered'] == False:
continue
title = quest['title']
print('Question :- {0}'.format(title))
question_id = quest['question_id']
print('Question ID :- {0}'.format(question_id))
top_answer = SITE.fetch('questions/' + str(question_id) + '/answers', order = 'desc', sort='votes')
print('Most Voted Answer ID :- {0}'.format(top_answer['items'][0]['answer_id']))
现在使用这个answer_id我想得到那个答案的正文。我可以通过使用此 API 链接获取其余详细信息。
慕标琳琳
相关分类