cl-yahoo
CL-YAHOO is a Common Lisp interface to the Yahoo! API, a web API which enables searching the web through yahoo. Web-search, image-search, spelling, news-search, local search (searching for business in your area), contextual search, and term extraction are supported.

Current version is 0.5.

It requires S-XML and TRIVIAL-HTTP.

Tested on SBCL, Clisp, and ACL 6.2, on RH9/x86.

Author: Martin Elster ASDF-install package (obsolete) http://folk.uio.no/melster/cl-yahoo-latest.tar.gz

-- the link is broken 2007-11-22

Examples:

Searching the web for Lisp, returning 2 results starting at result number 3:

(ysearch :web :query "lisp" :type 'any :results 2 :start 3)

This query returns a list of objects, each representing the results of the search. To see the "summary" field of the first response from yahoo, use the following:

CL-USER> (summary (first (ysearch :web :query "lisp" :type 'any :results 2 :start 3 :adult-ok 1)))
"... The benefits of Common Lisp and CLISP. why is ANSI Common Lisp such a great programming environment? ..."
CL-USER>

Searching for a lisp jpg image;

(ysearch :image :query "lisp" :format 'jpg)

Checking spelling:

CL-USER> (ysearch :spelling :query "improbabble")
improbable
CL-USER>

Finding the phone number of three pizza joints in zip code 94306:

CL-USER> (mapcar #'phone (ysearch :local :query "pizza" :results 3 :zip 94306))
("(650) 494-2928" "(650) 424-9400" "(650) 326-6552")
CL-USER> 

Term extraction:

CL-USER> (yahoo:ysearch :term-extraction :context "Italian sculptors and painters of the renaissance favored the Virgin Mary for inspiration." :query "madonna")
("italian sculptors" "virgin mary" "painters" "renaissance" "inspiration")
CL-USER> 

See README file for more details and examples, or the CHANGES.


I'm using SBCL 1.0.2 on Ubuntu Edgy and ran into problems getting Web search to work:

CL-USER> (asdf:oos 'asdf:load-op :cl-yahoo)                                                                                    
NIL                                                                                                                            
CL-USER> (use-package :cl-yahoo)                                                                                               
T                                                                                                                              
CL-USER> (ysearch :web :query "lisp" :type 'any :results 2)
                                               
XML parser encountered eof before end of entity.                                                                               
   [Condition of type S-XML:XML-PARSER-ERROR]                                                                                  
                                                                                                                               
Restarts:                                                                                                                      
 0: [ABORT] Return to SLIME's top level.                                                                                       
 1: [TERMINATE-THREAD] Terminate this thread (#<THREAD "repl-thread" {CC416A9}>)                                               
                                                                                                                               
Backtrace:                                                                                                                     
  0: (S-XML::RESOLVE-ENTITY                                                                                                    
      #<SB-SYS:FD-STREAM for "a constant string" {B477469}> >                                                                  
      "invalid value: uri - http://api.search.yahoo.com/WebSearchService/V1/webSearch?"                                        
      #<HASH-TABLE :TEST EQUAL :COUNT 6 {B47C031}>                                                                             
      "appid=cl-yahoo&query=lisp&type=any&results=2&start=3&adult_ok=1</Message>^M                                             
     </Error>^M                                                                                                                
     <!-- ws02.search.scd.yahoo.com uncompressed Sat Mar  3 16:16:03 PST 2007 -->                                         > 
     ")                                                                                                                        
  1: (S-XML::PARSE-TEXT                                                                                                        
      #<SB-SYS:FD-STREAM for "a constant string" {B477469}>
...

I tried to email the author, but the email bounced.

-- 2007.03.04, Marc Abramowitz (http://marc.abramowitz.info, msabramo at yahoo dot com)


I'm getting the same problem in Allegro Lisp 8.0. It looks like Yahoo doesn't like something about the HTTP request, but I can't figure out what.


Since upstream seems to have died, you can get the source from a Gentoo project mirror: ftp://ibiblio.org/pub/linux/distributions/gentoo/distfiles/cl-yahoo-0.5.tar.gz

-- 2007.06.08, Mike Travers)