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>
