Skip to content

Instantly share code, notes, and snippets.

@baramutu
Created May 24, 2016 12:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save baramutu/56f3411e848978bd847ce73543ba4d82 to your computer and use it in GitHub Desktop.
Save baramutu/56f3411e848978bd847ce73543ba4d82 to your computer and use it in GitHub Desktop.
AlfredのGoogle Suggest Workflowのスクリプトフィルタを編集して、日本語の候補がより多く表示されるように改変したものです
require_once('workflows.php');
$wf = new Workflows();
$orig = "{query}";
$xml = $wf->request( "http://google.co.jp/complete/search?hl=ja&ie=utf_8&oe=utf_8&output=toolbar&q=".urlencode( $orig ) );
$xml = simplexml_load_string( $xml );
$int = 1;
foreach( $xml as $sugg ):
$data = $sugg->suggestion->attributes()->data;
$wf->result( $int.'.'.time(), "$data", "$data", 'Search Google for '.$data, 'icon.png' );
$int++;
endforeach;
$results = $wf->results();
if ( count( $results ) == 0 ):
$wf->result( 'googlesuggest', $orig, 'No Suggestions', 'No search suggestions found. Search Google for '.$orig, 'icon.png' );
endif;
echo $wf->toxml();
@baramutu
Copy link
Author

元ネタはこちら

Alfred付属のSuggest系ワークフローを一行で正常動作させる方法:
http://scrivguide.hatenadiary.jp/entry/2016/05/23/220554

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment