Is there a way to query Stack Overflow directly from the command line and get back the most upvoted answer to the first question that comes up for that query?
I really mislike having to open up my browser whenever I want to brush up on my knowledge of writing RegExes for matching XHTML tags.
You can find a link to the site's meta in two places in the site's top bar: under the "help" menu (the question-mark icon) in the upper right, and in the Stack Exchange site switcher (under the Stack Exchange in the upper right. Reopening a question follows the same process as closing a question.
First, make sure you've asked a good question. To get better answers, you may need to put additional effort into your question. Edit your question to provide status and progress updates. Document your own continued efforts to answer your question.
This question doesn't meet a Stack Overflow guideline. If you believe the question can be reworded to fit within the scope, consider editing the question or leaving comments for improvement. Note: If you choose this close reason, you will be shown another set of options (which vary by site):
Questions posted on Stack Overflow which are not related to programming topics, are marked as 'closed' by experienced users and community moderators. A question can be 'closed' for five reasons - duplicate, off-topic, subjective, not a real question and too localized.
Yes, it is possible! Try out Benjamin Gleitzman's excellent tool howdoi.
It works like this:
$ howdoi get stackoverflow answers inside a terminal
and the program will query StackOverflow for keywords "get stackoverflow answers inside a terminal", find the question that best matches these terms and return the code from the best answer to that question.
You can also add the -a
option to get the full answer, not just the code. So to get an answer for your example query, you would do:
$ howdoi -a RegEx match XHTML tags
If you have Python & pip installed, you can get it from the Cheese shop.
$ pip install howdoi
Enter howdoi -h
for complete usage instructions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With