new Web Services API and Perl, PHP, Java, Python, Ruby, or the programming language of your choice Visualize search results and topics, mash up images from around the Web, and remix othe
Trang 1By Paul Bausch
Publisher: O'Reilly Pub Date: October 2005 ISBN: 0-596-00945-3 Pages: 489
Yahoo! Hacks shows you how to use, expand, personalize, and tweak Yahoo! in ways you
never dreamed possible You'll learn how to:
Fine-tune search queries with keyword shortcuts and advanced syntax
Manage and customize Yahoo! Mail, using it as your universal email client to access all your other accounts
Explore your social networks with Yahoo! 360, blogging your life, keeping up with friends, and making new contacts
Store, sort, blog, feed, track, and otherwise share photos with Flickr and RSS
Make My Yahoo! your Yahoo!, and personalize Yahoo!'s many properties
Roll your own Yahoo! applications with Yahoo! new Web Services API and Perl, PHP, Java, Python, Ruby, or the programming language of your choice
Visualize search results and topics, mash up images from around the Web, and remix other web content
List (or hide) your site with Yahoo!, and integrate Yahoo! Groups, Messenger,
contextual search (Y!Q), or other Yahoo! features
Whether you want to become a power searcher, news monger, super shopper, or
Trang 2ever thought possible.
Trang 3By Paul Bausch
Publisher: O'Reilly Pub Date: October 2005 ISBN: 0-596-00945-3 Pages: 489
Trang 7Printed in the United States of America
Published by O'Reilly Media, Inc., 1005 Gravenstein HighwayNorth, Sebastopol, CA 95472
O'Reilly books may be purchased for educational, business, orsales promotional use Online editions are also available for
most titles (safari.oreilly.com) For more information, contact
our corporate/institutional sales department: (800) 998-9938 orcorporate@oreilly.com
Table
Series Editor: Rael Dornfest Cover Designer: Hanna Dyer
Executive Editor: Dale Dougherty Interior Designer: David Futato
Trang 8While every precaution has been taken in the preparation of thisbook, the publisher and author assume no responsibility for
errors or omissions, or for damages resulting from the use ofthe information contained herein
Small print: The technologies discussed in this publication, the
limitations on these technologies that technology and contentowners seek to impose, and the laws actually limiting the use ofthese technologies are constantly changing Thus, some of thehacks described in this publication may not work, may causeunintended harm to systems on which they are used, or maynot be consistent with applicable user agreements Your use ofthese hacks is at your own risk, and O'Reilly Media, Inc
disclaims responsibility for any damage or expense resultingfrom their use In any event, you should take care that your use
of these hacks does not violate any applicable laws, includingcopyright laws
This book uses RepKover™, a durable and flexible lay-flatbinding
ISBN: 0-596-00945-3
[C]
Trang 9About the AuthorContributors
Acknowledgments
Trang 10(Wiley), and maintains a directory of Oregon weblogs calledORblogs (http://www.orblogs.com) When he's not working on abook, Paul posts thoughts and photos to his personal weblog,
onfocus (http://www.onfocus.com)
Trang 11Lublin, Poland, with his wife, Gosia, and can be reached atjacek@artymiak.com
Bonnie Biafore is the author of several books about personalfinance, investing, and project management As an
engineer, she's tenaciously attentive to detail and digeststantalizing morsels about every topic she approaches Hersick sense of humor turns subjects that are droolinducing inother books into entertaining, easy reading Her book the
NAIC Stock Selection Handbook won major awards from
both the Society of Technical Communication and APEX
Awards for Publication Excellence, but she cherishes theraves she's received from beginning investors most of all
She is also the author of Online Investing Hacks (O'Reilly) and QuickBooks 2005: The Missing Manual (O'Reilly).
Bonnie writes a monthly column called WebWatch for Better
Investing magazine and is a regular contributor to
WomensWallStreet.com As a consultant, she manages
projects for clients and wins accolades for her ability to herdcats When not chained to her computer, she hikes in themountains with her dogs, cooks gourmet meals, and
practices saying no to additional work assignments You canlearn more at Bonnie's web site,
http://www.bonniebiafore.com, or email her at
bonnie.biafore@gmail.com
Trang 12(http://www.researchbuzz.com), a weekly newsletter onInternet searching and online information resources She'salso a regular columnist for Searcher magazine She's beenwriting about search engines and searching since 1996; her
imagine (like the popular open sourced syndicated readerAmphetaDesk, the best-kept gaming secret
Gamegrene.com, the popular Ghost Sites and NonsenseNetwork, the giggle-inducing articles at the O'Reilly
Network, a few pieces at Apple's Internet Developer site,etc.), he's an ardent supporter of cloning, merely so he canget more work done He cooks with a Fry Pan of Intellect+2 and lives in Concord, New Hampshire
Ryan Kennedy is a software engineer at Yahoo!, working onYahoo! Mail In his spare time, he maintains the Yahoo! JavaSearch SDK
Philipp Lenssen lives in Stuttgart, Germany, where he blogsabout Google, works as a programmer on an automobileweb site, and eats spicy Thai food with his girlfriend Helikes to ponder future technology and jump on any
technology bandwagon that seems worthwhile, especially allthe APIs that make a developer's life that much easier
Philipp's daily musings can be found at court.com
http://blog.outer-Mikel Maron is an independent software developer and
ecologist He has built several geographic-oriented projects
Trang 13My Yahoo! in the pre-RSS days Mikel was awarded a
master's degree from the University of Sussex for building asimulation of the evolution of complexity in food webs
Originally from California, Mikel is presently based mostly inBrighton, United Kingdom, with his wife, Anna Links to
various things can be found at http://brainoff.com
Deepak Nadig is an entrepreneur and has helped build
innovative and useful products for 14 years He is currentlytaking a break after cofounding and selling Covigna, a
pioneer in Contract Lifecycle Management
Todd Ogasawara focuses on Mobile Workforce and MobileLifestyle technology, paying special attention to the
Microsoft Windows Mobile platform (Pocket PC and
Smartphone) Microsoft has recognized his demonstratedpractical expertise and willingness to share his experience
by recognizing him as a Microsoft Most Valuable
Professional (MVP) in the Mobile Devices category since
2000 His other technology focus is in the effort to bringcommercial (especially Microsoft-related) products and
GNU/Open Source software together in a synergistic andproductive way Todd has written several articles about
mobile devices, digital cameras, and the Apple Mac Mini forthe O'Reilly Network He previously worked as a technologyanalyst for GTE/Verizon He also served as the contractedforum manager for the MSN.com (and later ZDNet)
Telephony Forum and Windows CE Forum More recently, hehas served as the eGovernment team leader for the State ofHawaii You can find his Mobile Workforce and Lifestyle
commentary at http://www.MobileViews.com You can learnmore about Eccentric Technology at
http://www.OgasaWalrus.com You can reach Todd by email
at Hacks@OgasaWalrus.com
Trang 14is a husband and father who lives in North Carolina with hiswife, his son, and his dog Mark spends his copious free
time sunbathing, skydiving, and reading Immanuel Kant's
Critique of Pure Reason in the original Klingon He can be
found stirring up trouble at http://diveintomark.org
Premshree Pillai is a geek working at Yahoo! He loves Ruby,beer, and classic rock He blogs at
http://www.livejournal.com/users/premshree
Eric Ries is currently CTO of IMVU, a startup creating 3-D,avatarbased instant messaging Eric also serves, in a
volunteer capacity, as CTO of the Taproot Foundation
Previously, he was senior software engineer at There andcofounder and CTO of Catalyst Recruiting He is author ofseveral free software projects, most recently the peer-to-peer RPC system Kenosis, and coauthor of several books,
including The Black Art of Java Game Programming and
Mastering Java.
Alan Taylor has been a web developer for over 10 years andhas worked for Monster.com, MSNBC.com, and
Amazon.com He builds web projects (such as Amazon
Light; http://kokogiak.com/amazon) and web hacks/toys on
an irregular basis, most of which can be found at
http://kokogiak.com Alan believes that open APIs are yourfriends and are positively the best trend on the Internet inyears
Trang 15
To my wife, Shawnde, thanks for the continuous feedback andfrontline editing, and for cheerfully discussing Yahoo! duringbreakfast, lunch, dinner, and every spare moment in between
Many thanks go to Brian Sawyer for providing direction and
encouragement, and for fine-tuning the text
checking facts, and adding important points to the technicaldetails
Thanks to tech editor Steve Champeon for testing code, double-Thanks to Morbus Iff for taking my Perl to task and simplifyingthe confusing bits
Finally, thanks to everyone at Yahoo! who contributed tips andhack ideas, including Vijay Anisetti, Stig Sæther Bakken, DaveBrown, Aurora Casanova, David Dueblin, Jennifer Dulski, MarcusFoster, David Hall, Jason B Silverstein, Jeremy Zawodny, andmany anonymous Yahoos Thanks also to Chris Kalaboukis andBernard Mangold at Yahoo! Research for lending a hand
Trang 16
Yahoo! is an impressive example of what can happen when ahobby takes on a life of its own In 1994, Jerry Yang and DavidFilo began publishing a personal list of sites they found
interesting on the emerging World Wide Web As "Jerry's Guide
to the World Wide Web" grew larger, the two Stanford grad
students began organizing the sites into categories, and thebasic structure of today's Yahoo! Directory was born By late
1994, they chose to rename their directory after the word
yahoo because its original definition describing a crude, rude
person appealed to the pair's subversive natures (And as truecomputer geeks, they turned Yahoo! into an acronym for YetAnother Hierarchical Officious Oracle.) Figure P-1 is a look atthe Yahoo! home page from December 1994
Yahoo! looks very different today Figure P-2 shows the morefamiliar Yahoo! home page of 2005
Though the two Yahoo! home pages look radically different, theoriginal idea of taming the chaos of the World Wide Web andmaking it accessible to a wider audience remains According totheir vision statement, Yahoo! wants "to enable people to find,use, share, and expand all human knowledge." The goal of
furthering this vision, nicknamed FUSE (for "find, use, share,and expand"), can be found in every acquisition Yahoo! makesand every product Yahoo! releases Yahoo! has localized
versions of its offerings in dozens of countries, and the Yahoo!brand is recognized around the world Over the past 10 years,Yahoo! has become much more than a guide to the Web;
Yahoo! is a platform for visualizing and connecting with the
world
Many Yahoo! features are familiar to anyone who uses the Web.Millions of people use Yahoo! Search to find information on theWeb Millions more use Yahoo! Groups to share information and
Trang 17Figure I-1 Yahoo! in 1994
Over the past year, the FUSE philosophy has been a distinctfeature of Yahoo!'s newest services In February 2005, Yahoo!
Trang 18of friends In April 2005, Yahoo! introduced My Web, a way tosave and share search results while creating your own personalcategorized directory of the Web
This book aims to help you FUSE Yahoo! features and services
by introducing you to little-known corners of Yahoo!, by
reintroducing you to familiar Yahoo! services, and by showingyou examples of the many ways people are expanding Yahoo!
on their own Though the hacks might be crude and rude attimes, they're written in the same spirit of sharing somethinginteresting that inspired the creation of Yahoo! in the first place
Figure I-2 Yahoo! in 2005
Trang 20The term hacking has a bad reputation in the press They use it
to refer to someone who breaks into systems or wreaks havocwith computers as their weapon Among people who write code,
While Yahoo! itself has been around for over 10 years, it is
releasing new applications, web sites, and software at a blindingpace This book isn't intended to catalog everything Yahoo!
offers, but rather to introduce new technologies, such as Yahoo!Web Services, while showing novel ways to use perennial
offerings like Yahoo! Search, Yahoo! Mail, and Yahoo! Groups.Through the years, developers have scraped, poked, and
prodded every corner of Yahoo! for their own uses, and the
release of Yahoo! Web Services is like a welcome mat being putout for a wider audience of would-be hackers This book intends
to show you what's possible when you view Yahoo! as a
platform and inspire your inner hacker to take a new look atYahoo!
Trang 21
You can read this book from cover to cover if you like, but eachhack stands on its own, so feel free to browse and jump to thedifferent sections that interest you most If there's a
prerequisite you need to know about, a cross-reference willguide you to the right hack
Trang 22Running a hack on the command line invariably involves thefollowing steps:
1 Type the program into a garden-variety text editor: Notepad
on Windows, TextEdit on Mac OS X, vi or Emacs on
Unix/Linux, or anything else of the sort Save the file as
directedusually as scriptname.pl (the pl bit stands for Perl, the predominant programming language used in Yahoo!
Hacks).
Alternately, you can download the code for all of the hacksonline at http://www.oreilly.com/catalog/yahoohks, wherethere is a ZIP archive containing individual scripts saved astext files
2 Get to the command line on your computer or remote
server In Mac OS X, launch the Terminal (Applications
Utilities Terminal) In Windows, click the Start button,select Run…, type command, and hit the Enter/Return key onyour keyboard In Unix…well, we'll just assume you knowhow to get to the command line
3 Navigate to where you saved the script at hand This varies
from operating system to operating system, but usually
Trang 232 "Much Ado About Nothing Script" [http://www.signal42.com/much_ado_ about_nothing_script.asp]
The elllpsis (…) bit signifies that we've cut offthe output for brevity's sake
Trang 24safekeeping, importing into your spreadsheet application, ordisplaying on your web site This is as easy as:
Don't worry if you can't remember all of this; each command-CGI Scripts
CGI scriptsprograms that run on your web site and produce
pages dynamicallyare a little more complicated if you're not
used to them While fundamentally they're the same sorts of
Trang 25troublesome because setups vary so widely You might be
running your own server, your web site might be hosted on anInternet service provider's (ISP's) server, your content mightlive on a corporate intranet serveror anything in between
Since going through every possibility is beyond the scope of this(or any) book, you should check your ISP's knowledge base, orcall the ISP's technical support department, or ask your localsystem administrator for help
2 Move the script over to wherever your web site lives You
should have some directory on a server somewhere in
which all of your web pages (all those html files) and
images (ending in jpg, gif, etc.) live Within this directory, you'll probably see something called a cgi-bin directory: this
Unix/Linux or Mac OS X system, this usually entails typingthe following on the command line:
Trang 26$ chmod 755 scriptname.cgi
4 Now you should be able to point your web browser at the
script and have it run as expected, behaving in a mannersimilar to that described in the "Running the Hack" section
of the hack at hand
Just what URL you use, once again, varies widely It should,however, look something like
be a little more than the average newbie can bear, but there ishelp in the form of a famous frequently asked question (FAQ)archive: "The Idiot's Guide to Solving Perl CGI Problems."
Search for it and step through as directed
Learning to Code
Trang 27best-selling Learning Perl
(http://www.oreilly.com/catalog/lperl3), by Randal L Schwartzand Tom Phoenix, provides a good start Apply what you learn
to understanding and using the hacks in this book, perhapseven taking on the "Hacking the Hack" sections to tweak andfiddle with the scripts This is a useful way to get a little
programming under your belt if you're a searching nut, sinceit's always a little easier to learn how to program when youhave a task to accomplish and existing code to leaf through
Trang 28
The book is divided into several chapters, organized by subject:
Chapter 1, Search
This chapter shows you how to become a Yahoo! powersearcher by taking advantage of meta keywords to returnmore relevant results You'll also see how to use searchshortcuts to find instant answers to some common
questions This chapter tells you how to find popular searchphrases and technologies by analyzing Yahoo! Buzz, andwe'll pit Yahoo! against Google to see which search enginereturns the most relevant results
Chapter 2, Services
Yahoo! offers information about everything from stocks andbonds to movie and TV schedules This chapter shows someunique ways to use Yahoo! Web Services, including
monitoring your commute for problems, watching TV
schedules automatically for appearances by your favoritecelebrities, and visualizing your music collection
Chapter 3, Communicating
Use the hacks in this chapter to reach out and touch
someone You'll find hacks for managing your Yahoo! Mail,collaborating with Yahoo! Groups, and exploring your socialnetworks with Yahoo! 360 This chapter also shows someways to personalize Yahoo! Messenger and share your
Trang 29Chapter 4, Web Services
This chapter introduces you to the back door that Yahoo!has opened for developers You'll find bare-bones examples
Chapter 6, Webmastering
If you publish on the Web, you're well aware of the trafficYahoo! can send to your site This chapter shows how to getlisted and introduces you to other Yahoo! components youcan plug into your site
Trang 30The following is a list of the typographical conventions used inthis book:
Italics
Used to indicate URLs, filenames, filename extensions, anddirectory names For example, a path in the filesystem will
a command-line prompt
Constant width italic
Used in code examples and other excerpts to show sampletext to be replaced with your own values
Trang 31Used to indicate a cross-reference within the text
A carriage return ( ) at the end of a line of code is used todenote an unnatural line break; that is, you should not enterthese as two lines of code, but as one continuous line Multiplelines are used in these cases due to page-width constraints
You should pay special attention to notes set apart from thetext with the following icons:
This is a tip, suggestion, or general note It contains useful supplementary information about the topic at hand.
This is a warning or note of caution, often indicating that your money
or your privacy might be at risk.
The thermometer icons, found next to each hack, indicate therelative complexity of the hack:
beginner moderate expert
Trang 32This book is here to help you get your job done In general, youmay use the code in this book in your programs and
documentation You do not need to contact us for permissionunless you're reproducing a significant portion of the code Forexample, writing a program that uses several chunks of codefrom this book does not require permission Selling or
distributing a CD-ROM of examples from O'Reilly books does
require permission Answering a question by citing this bookand quoting example code does not require permission
Incorporating a significant amount of example code from this
book into your product's documentation does require
permission
We appreciate, but do not require, attribution An attributionusually includes the title, author, publisher, and ISBN For
example: "Yahoo! Hacks by Paul Bausch Copyright 2006
O'Reilly Media, Inc., 0-596-00945-3."
If you feel your use of code examples falls outside fair use orthe permission given above, feel free to contact us at
permissions@oreilly.com
Trang 33
When you see a Safari® Enabled icon on the cover ofyour favorite technology book, that means the book is availableonline through the O'Reilly Network Safari Bookshelf
Safari offers a solution that's better than e-books It's a virtuallibrary that lets you easily search thousands of top tech books,cut and paste code samples, download chapters, and find quickanswers when you need the most accurate, current information.Try it for free at http://safari.oreilly.com
Trang 34
We have tested and verified the information in this book to thebest of our ability, but you may find that features have changed(or even that we have made mistakes!) As a reader of this
book, you can help us to improve future editions by sending usyour feedback Please let us know about any errors,
inaccuracies, bugs, misleading or confusing statements, andtypos that you find anywhere in this book
Please also let us know what we can do to make this book moreuseful to you We take your comments seriously and will try toincorporate reasonable suggestions into future editions You canwrite to us at:
Trang 36To explore Hacks books online or to contribute a hack for futuretitles, visit:
http://hacks.oreilly.com
Trang 37
Hack 12 Streamline Browsing with the Yahoo! ToolbarHack 13 Customize the Firefox Quick Search Box
Hack 14 Spot Trends with Yahoo! Buzz
Hack 15 Find Hot Technologies at the Buzz GameHack 16 Tame Long Yahoo! URLs
Hack 17 Opt Out of Advertiser Cookies
Trang 39Many of us use search engines in the same way we we use
street signs We use them to navigate, to get our bearings, and
to pinpoint our destination We rarely stop to consider the signsthemselves or look for more information they might be telling
us As with street signs, we'd be lost without search engines,and by taking a few minutes to contemplate the Yahoo! WebSearch results page, you might find new ways to reach yourdestination
Take a look at Figure 1-1, which shows a Yahoo! Web Searchresults page for the query ancient greece
Figure 1-1 Yahoo! Web Search results
Trang 40Navigation bar
You'll find the gray navigation bar at the top of the page onmany pages at Yahoo! sites The bar provides a consistentway to get to the main Yahoo! page
(http://www.yahoo.com), the My Yahoo! portal [Hack
#34], and Yahoo! Mail [Hack #52] The bar also indicatesyour login status by displaying your Yahoo! ID [Hack #3]
or Guest, along with links that let you sign in to Yahoo! or
sign out You can also click the Help link at the far right ofthe navigation bar to read documentation about the site
Search links
Just above the search form, you'll find links to other Yahoo!searches, including Images, Video [Hack #11], the Yahoo!Directory [Hack #20], Yahoo! News [Hack #32], andYahoo! Shopping [Hack #47] You can click any of thesesearch links to search with the exact query you used at one
of the other Yahoo! Search properties so that you don'thave to retype your search term
Result count
Search results are returned as a number of pages, and