Py-StackExchange filter by tag

青春壹個敷衍的年華 提交于 2019-12-12 07:20:07

问题


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. python, loops, 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.


回答1:


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.



来源:https://stackoverflow.com/questions/19898666/py-stackexchange-filter-by-tag

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!