Here's a macro that does much of what you want. Maybe it is enough to get you started:
For more information, see the wiki Searching the Forum for Answers section.