Yahoo! search interface: Difference between revisions
Content added Content deleted
(+ D entry) |
No edit summary |
||
Line 1,021: | Line 1,021: | ||
nextpage()</lang> |
nextpage()</lang> |
||
=={{header|Racket}}== |
|||
<lang Racket>#lang racket |
|||
(require net/url) |
|||
(define *yaho-url* "http://search.yahoo.com/search?p=~a&b=~a") |
|||
(define *current-page* 0) |
|||
(define *current-query* "") |
|||
(define request (compose port->string get-pure-port string->url)) |
|||
;;strip html tags |
|||
(define (remove-tags text) |
|||
(regexp-replace* #px"<[^<]+?>" text "")) |
|||
;;search, parse and print |
|||
(define (search-yahoo query) |
|||
(unless (string=? *current-query* query) ;different query, go back to page 1 |
|||
(set! *current-query* query) |
|||
(set! *current-page* 0)) |
|||
(let* ([current-page (number->string (add1 (* 10 *current-page*)))] |
|||
[html (request (format *yaho-url* query current-page))] |
|||
[results (regexp-match* #px"lass=\"yschttl spt\" href=\".+?\">(.+?)<span class=url>(.+?)</span>.+?<div class=\"abstr\">(.+?)</div>" html #:match-select cdr)]) |
|||
(for ([result (in-list results)]) |
|||
(printf "Title: ~a \n Link: ~a \n Text: ~a \n\n" |
|||
(remove-tags (first result)) |
|||
(remove-tags (second result) ) |
|||
(remove-tags (third result)))))) |
|||
;;search nexxt page |
|||
(define (next-page) |
|||
(set! *current-page* (add1 *current-page*)) |
|||
(search-yahoo *current-query*))</lang> |
|||
# REPL: |
|||
<pre> |
|||
(search-yahoo "Rosetta") |
|||
Title: Partner With Our Interactive Marketing Agency Today | Rosetta |
|||
Link: www.rosetta.com |
|||
Text: Learn about the fastest growing interactive marketing agency in the country - Rosetta. Our strategic marketing planning is custom built and connects you with your ... |
|||
Title: Official Rosetta Stone® - Language Learning - Learn a Language |
|||
Link: www.rosettastone.com |
|||
Text: Learn a new language with Rosetta Stone®. SUMMER SALE! $349 Levels 1-5 Set + Free Shipping. Ending Soon! |
|||
Title: Rosetta (spacecraft) - Wikipedia, the free encyclopedia |
|||
Link: en.wikipedia.org/wiki/Rosetta_probe |
|||
Text: noun 1. a town in N Egypt, at a mouth of the Nile. 2. a female given name . Relevant Questions Why Was The Rosetta Ston... Who Is Rosetta Stone? Why Is The Rosetta ... |
|||
Title: Rosetta stone: Definition from Answers.com |
|||
Link: www.answers.com/topic/rosetta-stone |
|||
Text: Rosetta stone n. A basalt tablet bearing inscriptions in Greek and in Egyptian hieroglyphic and demotic scripts that w |
|||
Title: Rosetta (1999) - IMDb |
|||
Link: www.imdb.com/title/tt0200071 |
|||
Text: The first scene, like almost all others, is a fighting scene. A girl, about 18, is sacked from her factory work because her trial period is over. The girl, Rosetta ... |
|||
Title: Welcome to Rosetta Stone® Classroom |
|||
Link: salem-keizersd.rosettastoneclassroom.com |
|||
Text: Welcome to Rosetta Stone® Classroom. First Time Users; © 2013 Rosetta Stone Ltd. All rights reserved. |
|||
Title: Rosetta Hardscapes |
|||
Link: www.discoverrosetta.com/index.html |
|||
Text: Rosetta Hardscapes sells and licenses concrete pavers, fire pits, retaining walls and landscaping features with the colors and textures of natural stone. |
|||
(next-page) |
|||
Title: Rosetta Stone |
|||
Link: www.rosettastone.com/?prid=rosettaclassroom_com |
|||
Text: Find great prices & selection on Rosetta Stone language software for Windows & Mac; shop & buy titles to learn Spanish, French, & more. |
|||
Title: rosetta stone spanish | eBay - Electronics, Cars, Fashion ... |
|||
Link: www.ebay.com/sch/i.html?_nkw=rosetta+stone+spanish |
|||
Text: Find great deals on eBay for rosetta stone spanish and rosetta stone spanish latin america. Shop with confidence. |
|||
Title: Apple - Rosetta |
|||
Link: www.apple.com/asia/rosetta |
|||
Text: Applications bearing the Universal symbol will run natively on both Intel- and PowerPC-based Mac computers. What about the applications you already own? Enter Rosetta. |
|||
Title: Rosetta | Free Music, Tour Dates, Photos, Videos |
|||
Link: www.myspace.com/rosetta |
|||
Text: The International Rosetta Mission was approved in ... Lutetia is revealed by a comprehensive analysis of the data gathered by ESA's Rosetta spacecraft when it ... |
|||
Title: Amazon.com: rosetta stone |
|||
Link: www.amazon.com/s?ie=UTF8&page=1&rh=i%3Aaps%2Ck%3Arosetta... |
|||
Text: Rosetta Stone Spanish (Latin America) Level 1 by Rosetta Stone (CD-ROM - Sept. 14, 2010) - Mac OS X 10.6 Snow Leopard, Windows 7 / 8 / XP. Buy new: $179.00 . |
|||
Title: Rosetta - Disney Wiki |
|||
Link: disney.wikia.com/wiki/Rosetta |
|||
Text: Rosetta: Yea, no, I don't really do mud.Vidia: But, you're a garden fairy!Rosetta: Ironic, isn't... |
|||
Title: Rosetta - Hamilton, NJ - Company | Facebook |
|||
Link: www.facebook.com/rosetta |
|||
Text: Rosetta, Hamilton, NJ. 2,060 likes · 36 talking about this · 135 were here. We are currently ranked by Ad Age among the top US digital agencies and recently named ... |
|||
Title: Rosetta Stone (Game) - CNET Download.com |
|||
Link: download.cnet.com/Rosetta-Stone/3000-2111_4-10835868.html |
|||
Text: Whether your are playing Greek number mode or Egyptian letter mode, the number one rule to keep in mind is keeping the scales balanced but its not that ... |
|||
</pre> |
|||
=={{header|Ruby}}== |
=={{header|Ruby}}== |
||
{{improve|1=Ruby|2=Should not call <code>URI.escape</code>, because it fails to encode = signs and some other characters that might appear in the term. See [[URL encoding#Ruby]].}} |
{{improve|1=Ruby|2=Should not call <code>URI.escape</code>, because it fails to encode = signs and some other characters that might appear in the term. See [[URL encoding#Ruby]].}} |