Jump to content

Recommended Posts

StackOverflow Search for Alfred
 
Search for answers on StackOverflow.com from Alfred 2.

 

demo.gif
 
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 by deanishe

Share this post


Link to post

@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).

Share this post


Link to post

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).

Share this post


Link to post

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  :)

Share this post


Link to post

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).

Share this post


Link to post

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 by Wildcard
Clarify I'm willing to try myself

Share this post


Link to post
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.

Share this post


Link to post

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.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...