deanishe Posted December 29, 2014 Share Posted December 29, 2014 (edited) StackOverflow Search for Alfred Search for answers on StackOverflow.com from Alfred 2. Download Get StackOverflow for Alfred from GitHub or Packal. Usage .so <query> — Search StackOverflow.com for <query>. See below for syntax. ↩ or ⌘+NUM — Open result in default browser ⌘+L — Show full question title in Alfred's Large Text window Query syntax By default, words in <query> will be search for in the title of posts. To specify a tag, prefix it with ., e.g. python will search for python in the post title, .python will search for the tag python. Results Answered questions will be shown first in the list of results (and have a tick on their icon). Licensing, thanks This workflow is released under the MIT Licence. It is heavily based on Alfred-Workflow, also MIT-licensed. Edited December 29, 2014 by deanishe smarg19 and vdesabou 2 Link to comment
politicus Posted January 5, 2015 Share Posted January 5, 2015 @deanishe Great workflow. Thanks for sharing! Got this error message when typed the query "osx apple": Starting debug for 'Web Dev StackOverflow Search' [ERROR: alfred.workflow.input.scriptfilter] Code 0: 10:09:55 workflow.py:2194 DEBUG Update check not due 10:09:55 workflow.py:1945 DEBUG Workflow version : 1.0.0 10:09:55 workflow.py:1598 DEBUG Loading cached data from : /Users/user/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/net.deanishe.alfred-stackoverflow/__workflow_update_status.cpickle 10:09:55 workflow.py:2142 DEBUG update_data : {u'available': False} 10:09:55 so.py:127 DEBUG query : u'osx apple' 10:09:55 so.py:58 DEBUG Cache key : u'osxapple' [] -> u'osxapple' 10:09:56 so.py:92 DEBUG [200] https://api.stackexchange.com/2.2/search?sort=relevance&pagesize=50&site=stackoverflow&order=desc&intitle=osxapple&page=1 10:09:56 workflow.py:1634 DEBUG Cached data saved at : /Users/user/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/net.deanishe.alfred-stackoverflow/osxapple.cpickle 10:09:56 so.py:158 DEBUG 0 answers for u'osxapple', tagged [] 10:09:56 workflow.py:2124 DEBUG Set last run version : 1.0.0 10:09:56 workflow.py:1969 DEBUG Workflow finished in 0.407 seconds. Workflow version: 1.0 (downloaded from Packal). Link to comment
deanishe Posted January 5, 2015 Author Share Posted January 5, 2015 (edited) That's not an error. Alfred currently wrongly prefixes any output to STDERR with ERROR. Edited January 5, 2015 by deanishe Link to comment
politicus Posted January 5, 2015 Share Posted January 5, 2015 How do you explain I got zero results to the query "osx apple" using your workflow while I got 9659 results using stackoverflow.com? Link to comment
deanishe Posted January 5, 2015 Author Share Posted January 5, 2015 Because the workflow uses the API, which is not the same as the search function on the website. Read the instructions in the OP: Typing "osx apple" will search post titles. You need to type ".osx .apple" if you want to search for posts tagged with "osx" and "apple" (which returns plenty of results). Link to comment
politicus Posted January 5, 2015 Share Posted January 5, 2015 Thanks for the clarification. I red the instructions BUT was not sure how stackoverflow worked ( Did they use tags, titles, both ?). And yes, I have plenty of results using .osx .apple Link to comment
deanishe Posted January 5, 2015 Author Share Posted January 5, 2015 Well I'd say "osx" is much more likely to be a tag… Generally, I've had more luck with tags, but you have to mix and match. Unfortunately, there's no way to replicate the search function via the API. You got 50 results: that's the maximum number the workflow will retrieve (I think the API maxes out at 100). Link to comment
Wildcard Posted September 25, 2016 Share Posted September 25, 2016 (edited) This is pretty cool! Do you have any plans to make it accept an argument of which site to search? I looked into the Python code and I see that the "SITE" parameter can be modified, but since I am a routine visitor of unix.stackexchange, apple.stackexchange, superuser, stackoverflow, occasionally askubuntu, it would be nice if I could search any one of these...without making 5 copies of the entire workflow just to edit that one parameter! P.S.: I'm willing to attempt this myself, but I am a beginner with Python so I would need some tips, preferably from the original author. Now if it were in bash, I would have already edited it myself. Edited September 25, 2016 by Wildcard Clarify I'm willing to try myself Link to comment
deanishe Posted September 25, 2016 Author Share Posted September 25, 2016 40 minutes ago, Wildcard said: This is pretty cool! Do you have any plans to make it accept an argument of which site to search? No. I don't use any other StackExchange sites personally, and it's a significant amount of work to add useable support for all possible StackExchange sites. It'd probably be easy enough to build a multi-stage workflow with Alfred 3 that lets you choose the site first then search it (replacing SITE with a workflow variable). But that would suck for what I use it for, and to do it "properly" would be far more work than I'm every going to invest in the workflow. Link to comment
Wildcard Posted September 26, 2016 Share Posted September 26, 2016 Cool; makes sense. If I ever do anything with it I'll post it here, but I agree it's probably more work than it's worth. Link to comment
deanishe Posted September 26, 2016 Author Share Posted September 26, 2016 Unless you use literally loads of StackExchange sites, making a copy of the workflow for each site is a good solution. I don't envisage the workflow getting updated unless the SE API changes. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now