Once you’ve installed Stackoverflow Watcher you have two ways of using it:
- Run it using the “stack-watcher” command.
- Use the underlying library directly from your code.
Once you’re comfortable with this you can begin customising how it behaves by subclassing the main components. This provides a lot of flexibility and isn’t difficult. You can learn how to do this in the customising section and see examples of it in action in the examples directory.
Stackoverflow Watcher comes with the “stack-watcher” command. You can use this from the shell to start watching and filtering questions. The arguments are:
|--tag||What tag should we restrict the feed to?|
|--interval||How many seconds should we wait between feed requests?|
|--retriever||What Python class should we use for the Retriever?|
|--question||What Python class should we use for Question objects?|
If you wanted to watch all of the latest questions, with no filtering at all. You would use the command on it’s own like so:
Let’s say you wanted to watch only questions that have the html tag. You could use the `tag` argument like this:
$ stack-watcher --tag html
Stackoverflow Watcher also has an API which you can use directly in your own code. Here’s an example that does pretty much the same thing as the “stack-watcher” command with no arguments:
from stack_watcher import Retriever retriever = Retriever() for question in retriever.questions(): print(question)
This will continue retrieving and displaying new questions indefinitely.
If you wanted to restrict the questions to a specific tag you could pass the `tag` argument to Retriever like this:
from stack_watcher import Retriever retriever = Retriever(tag='html') for question in retriever.questions(): print(question)