Refer to these posts on Stack Apps:
- Get questions with body and answers
- How to get Question/Answer body in the API response using filters?
- My filter is not returning any results. How to create a minimal filter?
You need to use a custom filter to get question/answer/post bodies.
The good news is that you can also use the custom filter to get the answer data at the same time as you get the questions -- eliminating the need for later API calls.
For example, if you call the /questions
route with the filter:
!*SU8CGYZitCB.D*(BDVIficKj7nFMLLDij64nVID)N9aK3GmR9kT4IzT*5iO_1y3iZ)6W.G*
You get results like:
"items": [ {
"tags": ["python", "iterator", "generator", "yield", "coroutine"],
"answers": [ {
"owner": {"user_id": 8458, "display_name": "Douglas Mayle"},
"is_accepted": false,
"score": 248,
"creation_date": 1224800643,
"answer_id": 231778,
"body": "<p><code>yield</code> is just like <code>return</code> - it returns what..."
}, {
"owner": {"user_id": 22656, "display_name": "Jon Skeet"},
"is_accepted": false,
"score": 139,
"creation_date": 1224800766,
"answer_id": 231788,
"body": "<p>It's returning a generator. I'm not particularly familiar with Python, ..."
}, {
...
} ],
"owner": {"user_id": 18300, "display_name": "Alex. S."},
"is_answered": true,
"accepted_answer_id": 231855,
"answer_count": 40,
"score": 8742,
"creation_date": 1224800471,
"question_id": 231767,
"title": "What does the "yield" keyword do?"
},
...
So, change this:
questions = SITE.fetch('questions', min=20, tagged='python', sort='votes')
To something like this:
questions = SITE.fetch('questions', min=20, tagged='python', sort='votes', filter='!*SU8CGYZitCB.D*(BDVIficKj7nFMLLDij64nVID)N9aK3GmR9kT4IzT*5iO_1y3iZ)6W.G*')
then adjust your for
loop accordingly.