samrap samrap - 1 year ago 92
Python Question

Py-StackExchange filter by tag

I'm using Py-StackExchange to get a list of recent questions from Stack Overflow. I know there is a way to get just a constant list of questions:

import stackexchange

so = stackexchange.Site(stackexchange.StackOverflow)

for question in so.questions(pagesize=10):
print question

But this returns all questions across SO. I'm wondering if there is a parameter to filter the questions list by tag, i.e.
, etc to only return questions in that tag. I've been cruising the web for almost an hour searching for results, even reading through some of the scripts, but I can't find anything.

Answer Source

Use tagged keyword argument.

For example:

for question in so.questions(tagged=['python'], pagesize=10):
    print question
    assert 'python' in question.tags

Specifying tagged=['python', 'loops'] will filter question that is tagged both python and loops.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download