facebook twitter hatena line email

Google/カスタム検索

提供: 初心者エンジニアの簡易メモ
2015年10月12日 (月) 00:44時点におけるAdmin (トーク | 投稿記録)による版 (Admin がページ「Google検索/カスタム検索」を「Google/カスタム検索」に移動しました)

(差分) ←前の版 | 最新版 (差分) | 次の版→ (差分)
移動: 案内検索

Google検索のサイト

https://cse.google.co.jp/cse/all

urlパラメータを渡し結果のみをGoogle検索で表示する方法

検索エンジン選択/デザイン/レイアウト/結果のみを選択/コードを取得

結果のみ表示するコードを貼る

<script>
 (function() {
   var cx = '003685xxxxxxxxxxxxxx:wepxuxxxxx';
   var gcse = document.createElement('script');
   gcse.type = 'text/javascript';
   gcse.async = true;
   gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
       '//cse.google.com/cse.js?cx=' + cx;
   var s = document.getElementsByTagName('script')[0];
   s.parentNode.insertBefore(gcse, s);
 })();
</script>
<gcse:searchresults-only>Loading...</gcse:searchresults-only>

こんな感じでキーワードパラメータを渡す。 http://example.com/?q=hogehoge

pagerのclass属性定義

以下のようになってるので独自にcssを当てれば良い。

<div class="gsc-cursor">
<div class="gsc-cursor-page" tabindex="0">1</div>
<div class="gsc-cursor-page gsc-cursor-current-page" tabindex="0">2</div>
</div>