Skip to content

Instantly share code, notes, and snippets.

@arademaker
Created February 22, 2014 02:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arademaker/9147706 to your computer and use it in GitHub Desktop.
Save arademaker/9147706 to your computer and use it in GitHub Desktop.
(ql:quickload :drakma)
(ql:quickload :st-json)
(defun show-google-hits (term key ck)
(let* ((query (list (cons "key" key)
(cons "cx" ck)
(cons "q" term)))
(stream (drakma:http-request "https://www.googleapis.com/customsearch/v1"
:parameters query
:want-stream t)))
(setf (flexi-streams:flexi-stream-external-format stream) :utf-8)
(let* ((doc (yason:parse stream :object-as :alist))
(res (cadr (assoc "items" doc :test #'equal))))
(list (cdr (assoc "link" res :test #'equal))
(cdr (assoc "title" res :test #'equal))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment