poritsky Posted May 8, 2014 Share Posted May 8, 2014 Just wanted to bubble up a new post to let you know I just updated my DuckDuckGo workflow from over a year ago to support the new (and lovely) DuckDuckGo Next. This is still a mod of David Ferguson's awesome Google Suggest Workflow. The only difference is that it uses DuckDuckGo Next to do the actual search. More details over on the candler blog. Download Google Auto Complete to DDG Next.zip DuckDuckGo Next actually has autocompletions, but I wouldn't know how to get those into the Alfred workflow yet. For now the autocompletions still go through Google Suggest. Here's a vintage screenshot: Enjoy and happy searching! Jono 1 Link to comment
Jono Posted May 9, 2014 Share Posted May 9, 2014 Thanks, I came here looking for a new 'next' version. Link to comment
paulw Posted May 9, 2014 Share Posted May 9, 2014 (edited) I dug around in the ddg next code and found the url call for its autocomplete results: https://duckduckgo.com/ac/?q=query where "query" is whatever you're searching for. Google's autocorrect results are output as xml, and the workflow is set up to parse that. DDG's autocorrect outputs a series of strings in curly braces. Maybe someone with php knowhow can adapt the script so it parses DDG's results intead? Edit: Apparently it's JSON that ddg's autocomplete outputs. Edited May 9, 2014 by paulw Link to comment
paulw Posted May 10, 2014 Share Posted May 10, 2014 (edited) Okay, I cobbled together something retrieves and parses DuckDuckGo's native search suggestions. Feel free to use it (or improve it) to update your workflow. require_once('workflows.php'); $wf = new Workflows(); $orig = "{query}"; $json = $wf->request( "https://duckduckgo.com/ac/?q=".urlencode($orig)); $json = utf8_encode($json); $items = json_decode($json,true); $int = 1; foreach($items as $item): foreach($item as $suggestion): $wf->result( $int.'.'.time(), "$suggestion", "$suggestion", 'Search DuckDuckGo for '.$suggestion, 'icon.png' ); endforeach; endforeach; $results = $wf->results(); if ( count( $results ) == 0 ): $wf->result( 'ddgsuggest', $orig, 'Search DuckDuckGo for '.$orig, 'No suggested matches, search DuckDuckGo for '.$orig, 'icon.png' ); endif; echo $wf->toxml(); Edited May 10, 2014 by paulw Jono 1 Link to comment
paulw Posted May 10, 2014 Share Posted May 10, 2014 @Jono: just edited it slightly, in case you got the earlier version (only removes a couple of unnecessary bits). Link to comment
paulw Posted May 10, 2014 Share Posted May 10, 2014 I made an additional change in my version of the script filter on my machine: I want to be able to search for the original term as entered if I don't like the search suggestions. I would have liked to be able to use a modifier key to do that, but couldn't figure out how, since the original {query} is no longer available and has been replaced by the search suggestions. So I cut out the fallback part of the script (if there are no suggestions) and instead added a first item to the results list that matches the original search term. require_once('workflows.php'); $wf = new Workflows(); $orig = "{query}"; $wf->result( 'ddgignoresuggest', $orig, 'Search DuckDuckGo for '.$orig, 'Search DuckDuckGo for '.$orig.' or search suggestions below', 'icon.png' ); $json = $wf->request( "https://duckduckgo.com/ac/?q=".urlencode($orig)); $json = utf8_encode($json); $items = json_decode($json,true); $int = 1; foreach($items as $item): foreach($item as $suggestion): $wf->result( $int.'.'.time(), "$suggestion", "$suggestion", 'Search DuckDuckGo for '.$suggestion, 'icon.png' ); endforeach; endforeach; echo $wf->toxml(); Jono 1 Link to comment
Jono Posted May 11, 2014 Share Posted May 11, 2014 I prefer that, thanks again paulw 1 Link to comment
Davide Posted July 27, 2014 Share Posted July 27, 2014 Big thanks to poritsky and paulw! Great workflow! But does autocomplete also work with German Umlauts like ü, ö, ä? I get results like fÃ1/4r instead of für. Link to comment
paulw Posted July 27, 2014 Share Posted July 27, 2014 Big thanks to poritsky and paulw! Great workflow! But does autocomplete also work with German Umlauts like ü, ö, ä? I get results like fÃ1/4r instead of für. It looks like all that's required is to remove this line: $json = utf8_encode($json); It doesn't seem like removing it breaks anything. Here's the updated script filter: require_once('workflows.php'); $wf = new Workflows(); $orig = "{query}"; $wf->result( 'ddgignoresuggest', $orig, 'Search DuckDuckGo for '.$orig, 'Search DuckDuckGo for '.$orig.' or search suggestions below', 'icon.png' ); $json = $wf->request( "https://ac.duckduckgo.com/ac/?q=".urlencode($orig)); $items = json_decode($json,true); $int = 1; foreach($items as $item): foreach($item as $suggestion): $wf->result( $int.'.'.time(), "$suggestion", "$suggestion", 'Search DuckDuckGo for '.$suggestion, 'icon.png' ); endforeach; endforeach; echo $wf->toxml(); Link to comment
Davide Posted July 28, 2014 Share Posted July 28, 2014 Thanks Paul! Terrific! paulw 1 Link to comment
mnisbet Posted July 30, 2015 Share Posted July 30, 2015 Would be great if this worked with the bangs functionality - https://duckduckgo.com/bang Link to comment
deanishe Posted August 4, 2015 Share Posted August 4, 2015 I looked into this for my Searchio! workflow. DDG's search suggestion API doesn't support bangs. You might be able to hack something together by parsing the HTML or hacking some unofficial API, but that would be slow and liable to break. 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