Created
May 24, 2016 12:59
-
-
Save baramutu/56f3411e848978bd847ce73543ba4d82 to your computer and use it in GitHub Desktop.
AlfredのGoogle Suggest Workflowのスクリプトフィルタを編集して、日本語の候補がより多く表示されるように改変したものです
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
元ネタはこちら
Alfred付属のSuggest系ワークフローを一行で正常動作させる方法:
http://scrivguide.hatenadiary.jp/entry/2016/05/23/220554