! Copyright (C) 2011 John Benediktsson ! See http://factorcode.org/license.txt for BSD license USING: accessors assocs.extras classes.tuple colors combinators formatting http.client io io.styles json.reader kernel sequences urls wrap.strings ; IN: google.search : google-search ( query -- results ) search-url http-get nip json> { "responseData" "results" } deep-of [ \ search-result from-slots ] map ; url H{ { font-name "monospace" } { foreground COLOR: dark-green } } [ write-object ] with-style nl ; PRIVATE> : google-search. ( query -- ) [ "Search results for '%s'" sprintf write-heading nl ] [ google-search ] bi [ { [ titleNoFormatting>> write-title ] [ content>> write-content ] [ unescapedUrl>> write-url ] } cleave nl ] each ;