Skip to content

Instantly share code, notes, and snippets.

@yoshimana
Forked from baramutu/alfred_google_suggest_j.php
Created February 11, 2019 04:06
Show Gist options
  • Save yoshimana/ef640cfb25bc5d739bfcb585d929d775 to your computer and use it in GitHub Desktop.
Save yoshimana/ef640cfb25bc5d739bfcb585d929d775 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();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment