Friday, July 14, 2006

yahoo hacks only 4 lovish's readers

This document was created by Lovish




Contents


Yahoo! Hacks
Table of Contents
Copyright
Credits
About the Author
Contributors
Acknowledgments
Preface
Why Yahoo! Hacks?
How to Use This Book
How to Run the Hacks
How This Book Is Organized
Conventions Used in This Book
Using Code Examples
Safari Enabled
How to Contact Us
Got a Hack?
Chapter 1. Search
Section 1.1. Hacks 122: Introduction
Hack 1. Fine-Tune Yahoo! Web Search Queries
Hack 2. Save Time with Search Shortcuts
Hack 3. Create a Yahoo! ID
Hack 4. Set Persistent Yahoo! Search Preferences
Hack 5. Assemble Advanced Search Queries
Hack 6. Translate Any Page with Yahoo!
Hack 7. Personalize, Track, and Share the Web
Hack 8. Prefetch Yahoo! Search Results
Hack 9. Compare Yahoo! and Google Search Results
Hack 10. Find Content You Can Reuse Legally
Hack 11. Find Video from Across the Web
Hack 12. Streamline Browsing with the Yahoo! Toolbar
Hack 13. Customize the Firefox Quick Search Box
Hack 14. Spot Trends with Yahoo! Buzz
Hack 15. Find Hot Technologies at the Buzz Game
Hack 16. Tame Long Yahoo! URLs
Hack 17. Opt Out of Advertiser Cookies
Hack 18. Track News About Yahoo!
Hack 19. Spider the Yahoo! Catalog
Hack 20. Browse the Yahoo! Directory
Hack 21. Track Additions to Yahoo!
Hack 22. Yahoo! Directory Mindshare in Google
Chapter 2. Services
Section 2.1. Hacks 2350: Introduction
Hack 23. Track Your Investments
Hack 24. Build Your Own Stock Update Email
Hack 25. Download Financial Data Using Excel Web Queries
Hack 26. Convert Currencies with One Click
Hack 27. Do the Math with Yahoo! Calculators
Hack 28. Add a Yahoo! Bookmark with One Click
Hack 29. Import Existing Bookmarks into Yahoo! Bookmarks
Hack 30. Open Yahoo! Bookmarks in a Sidebar
Hack 31. Publish Your Yahoo! Bookmarks
Hack 32. Track the Media's Attention Span over Time
Hack 33. Monitor the News with RSS
Hack 34. Personalize My Yahoo!
Hack 35. Track Your Favorite Sites with RSS
Hack 36. Add a Feed to My Yahoo! with a Right-Click
Hack 37. Build Your Own News Crawler
Hack 38. Replace Your Phone Book with Yahoo!
Hack 39. Monitor Your Commute
Hack 40. Get the Facts at Yahoo! Reference
Hack 41. Find and Rate Movies
Hack 42. Subscribe to Movie Showtimes
Hack 43. View Movie Lists on Your Cell Phone
Hack 44. Plan Your TV Viewing
Hack 45. Create a TV Watch List
Hack 46. Develop and Share a Trip Itinerary
Hack 47. Shop Intelligently
Hack 48. Visualize Your Music Collection
Hack 49. Take Yahoo! on the Go
Hack 50. Stay Connected with Yahoo! Alerts
Chapter 3. Communicating
Section 3.1. Hacks 5167: Introduction
Hack 51. Navigate Yahoo! Mail
Hack 52. Manage Yahoo! Mail
Hack 53. Create Yahoo! Mail Macros
Hack 54. Read All Your Email in One Place
Hack 55. Read Yahoo! Mail in Your Preferred Email Client
Hack 56. Manage and Share Your Schedule
Hack 57. Add Contacts to Your Yahoo! Address Book
Hack 58. Map Yahoo! Address Book Contacts
Hack 59. Discuss, Share, and Collaborate with Others
Hack 60. Archive Yahoo! Groups Messages with yahoo2mbox
Hack 61. Explore Your Social Networks
Hack 62. Import an Existing Blogroll to Yahoo! 360
Hack 63. Add an API to Your Yahoo! 360 Blog
Hack 64. Create a Yahoo! Avatar
Hack 65. Add a Content Tab to Yahoo! Messenger
Hack 66. Send Instant Messages Beyond Yahoo!
Hack 67. Store, Sort, and Share Your Photos
Chapter 4. Web Services
Section 4.1. Hacks 6876: Introduction
Section 4.2.
Hack 68. Program Yahoo! with Perl
Hack 69. Program Yahoo! with PHP 5
Hack 70. Program Yahoo! with Python
Hack 71. Program Yahoo! with VBScript
Hack 72. Program Yahoo! with ColdFusion
Hack 73. Program Yahoo! with XSLT
Hack 74. Program Yahoo! with Java
Hack 75. Program Yahoo! with Ruby
Hack 76. Program Yahoo! with REBOL
Chapter 5. Applications
Section 5.1. Hacks 7791: Introduction
Hack 77. Visualize Yahoo! Web Search Results
Hack 78. Find Links to Any Web Site
Hack 79. Import Yahoo! Local Listings into Your Address Book
Hack 80. Create a Yahoo! Local MIDlet
Hack 81. Import Yahoo! Local Listings into Excel
Hack 82. Spell Words with Yahoo! Images
Hack 83. Randomize Your Windows Desktop Background
Hack 84. Randomize Your Mac Desktop Background
Hack 85. Mash Up Images from Around the Web
Hack 86. Illustrate Any Web Site
Hack 87. Add Links to a Block of Text Automatically
Hack 88. Visualize News Topics as Tags
Hack 89. Get Related Terms Instantly with Ajax
Hack 90. Compare the Popularity of Related Search Terms
Hack 91. Plot Multiple Points on Your Own Map
Chapter 6. Webmastering
Section 6.1. Hacks 92100: Introduction
Hack 92. Get Your Site Listed at Yahoo!
Hack 93. Hide Part of Your Web Site from Yahoo!
Hack 94. Search Your Web Site with Yahoo!
Hack 95. Add Presence to Your Web Site
Hack 96. Syndicate Rich Media
Hack 97. Add Contextual Search to Your Blog
Hack 98. Post Photos to Your Blog
Hack 99. Feed Your Latest Photos to Your Web Site
Hack 100. Display Messages from a Yahoo! Group on Your Web Site
Colophon
Index
SYMBOL
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z













Yahoo! Hacks
By Paul Bausch
...............................................
Publisher: O'Reilly
Pub Date: October 2005
ISBN: 0-596-00945-3
Pages: 489










Table of Contents | Index






Yahoo! took the world by storm in the 1990s as a one-of-a-kind, searchable
list of interesting web sites. But ten years later, it has expanded into a
department store overflowing with useful and innovative tools and
services-from email, blogging, social networking, and instant messaging,
to news, financial markets, shopping, movie and TV listings, and much
more. Today's Yahoo! keeps you connected with every aspect of your life
and every corner of the Web.




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 innovative web developer, Yahoo! Hacks provides the tools to take you
further than you ever thought possible.













Yahoo! Hacks
By Paul Bausch
...............................................
Publisher: O'Reilly
Pub Date: October 2005
ISBN: 0-596-00945-3
Pages: 489










Table of Contents | Index






Copyright

Credits


About the Author


Contributors


Acknowledgments

Preface


Why Yahoo! Hacks?


How to Use This Book


How to Run the Hacks


How This Book Is Organized


Conventions Used in This Book


Using Code Examples


Safari Enabled


How to Contact Us


Got a Hack?

Chapter 1. Search


Section 1.1. Hacks 122: Introduction


Hack 1. Fine-Tune Yahoo! Web Search Queries


Hack 2. Save Time with Search Shortcuts


Hack 3. Create a Yahoo! ID


Hack 4. Set Persistent Yahoo! Search Preferences


Hack 5. Assemble Advanced Search Queries


Hack 6. Translate Any Page with Yahoo!


Hack 7. Personalize, Track, and Share the Web


Hack 8. Prefetch Yahoo! Search Results


Hack 9. Compare Yahoo! and Google Search Results


Hack 10. Find Content You Can Reuse Legally


Hack 11. Find Video from Across the Web


Hack 12. Streamline Browsing with the Yahoo! Toolbar


Hack 13. Customize the Firefox Quick Search Box


Hack 14. Spot Trends with Yahoo! Buzz


Hack 15. Find Hot Technologies at the Buzz Game


Hack 16. Tame Long Yahoo! URLs


Hack 17. Opt Out of Advertiser Cookies


Hack 18. Track News About Yahoo!


Hack 19. Spider the Yahoo! Catalog


Hack 20. Browse the Yahoo! Directory


Hack 21. Track Additions to Yahoo!


Hack 22. Yahoo! Directory Mindshare in Google

Chapter 2. Services


Section 2.1. Hacks 2350: Introduction


Hack 23. Track Your Investments


Hack 24. Build Your Own Stock Update Email


Hack 25. Download Financial Data Using Excel Web Queries


Hack 26. Convert Currencies with One Click


Hack 27. Do the Math with Yahoo! Calculators


Hack 28. Add a Yahoo! Bookmark with One Click


Hack 29. Import Existing Bookmarks into Yahoo! Bookmarks


Hack 30. Open Yahoo! Bookmarks in a Sidebar


Hack 31. Publish Your Yahoo! Bookmarks


Hack 32. Track the Media's Attention Span over Time


Hack 33. Monitor the News with RSS


Hack 34. Personalize My Yahoo!


Hack 35. Track Your Favorite Sites with RSS


Hack 36. Add a Feed to My Yahoo! with a Right-Click


Hack 37. Build Your Own News Crawler


Hack 38. Replace Your Phone Book with Yahoo!


Hack 39. Monitor Your Commute


Hack 40. Get the Facts at Yahoo! Reference


Hack 41. Find and Rate Movies


Hack 42. Subscribe to Movie Showtimes


Hack 43. View Movie Lists on Your Cell Phone


Hack 44. Plan Your TV Viewing


Hack 45. Create a TV Watch List


Hack 46. Develop and Share a Trip Itinerary


Hack 47. Shop Intelligently


Hack 48. Visualize Your Music Collection


Hack 49. Take Yahoo! on the Go


Hack 50. Stay Connected with Yahoo! Alerts

Chapter 3. Communicating


Section 3.1. Hacks 5167: Introduction


Hack 51. Navigate Yahoo! Mail


Hack 52. Manage Yahoo! Mail


Hack 53. Create Yahoo! Mail Macros


Hack 54. Read All Your Email in One Place


Hack 55. Read Yahoo! Mail in Your Preferred Email Client


Hack 56. Manage and Share Your Schedule


Hack 57. Add Contacts to Your Yahoo! Address Book


Hack 58. Map Yahoo! Address Book Contacts


Hack 59. Discuss, Share, and Collaborate with Others


Hack 60. Archive Yahoo! Groups Messages with yahoo2mbox


Hack 61. Explore Your Social Networks


Hack 62. Import an Existing Blogroll to Yahoo! 360


Hack 63. Add an API to Your Yahoo! 360 Blog


Hack 64. Create a Yahoo! Avatar


Hack 65. Add a Content Tab to Yahoo! Messenger


Hack 66. Send Instant Messages Beyond Yahoo!


Hack 67. Store, Sort, and Share Your Photos

Chapter 4. Web Services


Section 4.1. Hacks 6876: Introduction


Section 4.2.


Hack 68. Program Yahoo! with Perl


Hack 69. Program Yahoo! with PHP 5


Hack 70. Program Yahoo! with Python


Hack 71. Program Yahoo! with VBScript


Hack 72. Program Yahoo! with ColdFusion


Hack 73. Program Yahoo! with XSLT


Hack 74. Program Yahoo! with Java


Hack 75. Program Yahoo! with Ruby


Hack 76. Program Yahoo! with REBOL

Chapter 5. Applications


Section 5.1. Hacks 7791: Introduction


Hack 77. Visualize Yahoo! Web Search Results


Hack 78. Find Links to Any Web Site


Hack 79. Import Yahoo! Local Listings into Your Address Book


Hack 80. Create a Yahoo! Local MIDlet


Hack 81. Import Yahoo! Local Listings into Excel


Hack 82. Spell Words with Yahoo! Images


Hack 83. Randomize Your Windows Desktop Background


Hack 84. Randomize Your Mac Desktop Background


Hack 85. Mash Up Images from Around the Web


Hack 86. Illustrate Any Web Site


Hack 87. Add Links to a Block of Text Automatically


Hack 88. Visualize News Topics as Tags


Hack 89. Get Related Terms Instantly with Ajax


Hack 90. Compare the Popularity of Related Search Terms


Hack 91. Plot Multiple Points on Your Own Map

Chapter 6. Webmastering


Section 6.1. Hacks 92100: Introduction


Hack 92. Get Your Site Listed at Yahoo!


Hack 93. Hide Part of Your Web Site from Yahoo!


Hack 94. Search Your Web Site with Yahoo!


Hack 95. Add Presence to Your Web Site


Hack 96. Syndicate Rich Media


Hack 97. Add Contextual Search to Your Blog


Hack 98. Post Photos to Your Blog


Hack 99. Feed Your Latest Photos to Your Web Site


Hack 100. Display Messages from a Yahoo! Group on Your Web Site

Colophon

Index















Copyright © 2006 O'Reilly Media, Inc. All rights reserved.


Printed in the United States of America.


Published by O'Reilly Media, Inc., 1005 Gravenstein Highway North,
Sebastopol, CA 95472.


O'Reilly books may be purchased for educational, business, or sales
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 or
corporate@oreilly.com.


Table


Editor:

Brian Sawyer

Production Editor:

A. J. Fox


Series Editor:

Rael Dornfest

Cover Designer:

Hanna Dyer


Executive Editor:

Dale Dougherty

Interior Designer:

David Futato


Printing History:





October 2005:

First Edition.







Nutshell Handbook, the Nutshell Handbook logo, and the O'Reilly logo are
registered trademarks of O'Reilly Media, Inc. The Hacks series
designations, Yahoo! Hacks, the image of boots and spurs, and related
trade dress are trademarks of O'Reilly Media, Inc.


Many of the designations used by manufacturers and sellers to distinguish
their products are claimed as trademarks. Where those designations appear
in this book, and O'Reilly Media, Inc., was aware of a trademark claim,
the designations have been printed in caps or initial caps.


While every precaution has been taken in the preparation of this book, the
publisher and author assume no responsibility for errors or omissions, or
for damages resulting from the use of the information contained herein.


Small print: The technologies discussed in this publication, the
limitations on these technologies that technology and content owners seek
to impose, and the laws actually limiting the use of these technologies
are constantly changing. Thus, some of the hacks described in this
publication may not work, may cause unintended harm to systems on which
they are used, or may not be consistent with applicable user agreements.
Your use of these hacks is at your own risk, and O'Reilly Media, Inc.
disclaims responsibility for any damage or expense resulting from their
use. In any event, you should take care that your use of these hacks does
not violate any applicable laws, including copyright laws.


This book uses RepKover™, a durable and flexible lay-flat binding.


ISBN: 0-596-00945-3


[C]















Credits



About the Author


Contributors


Acknowledgments
















About the Author


Paul Bausch is an independent web developer living in Corvallis, Oregon.
When he's not hacking together web applications, he's writing about
hacking together web applications. He put together Amazon Hacks for
O'Reilly in 2003. Paul also helped create the popular weblog application
Blogger (http://www.blogger.com/), cowrote a book about weblogs called We
Blog: Publishing Online with Weblogs (Wiley), and maintains a directory of
Oregon weblogs called ORblogs (http://www.orblogs.com/). When he's not
working on a book, Paul posts thoughts and photos to his personal weblog,
onfocus (http://www.onfocus.com/).


















Contributors


The following people contributed their hacks, writing, and inspiration to
this book:



Jacek Artymiak (http://www.artymiak.com/) is a freelance consultant,
developer, and writer. He's been programming computers since 1986,
starting with the Sinclair ZX Spectrum. His interests include network
security, computer graphics and animation, and multimedia. Jacek lives
in Lublin, Poland, with his wife, Gosia, and can be reached at
jacek@artymiak.com.



Bonnie Biafore is the author of several books about personal finance,
investing, and project management. As an engineer, she's tenaciously
attentive to detail and digests tantalizing morsels about every topic
she approaches. Her sick sense of humor turns subjects that are
droolinducing in other 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 the raves 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 herd cats.
When not chained to her computer, she hikes in the mountains with her
dogs, cooks gourmet meals, and practices saying no to additional work
assignments. You can learn more at Bonnie's web site,
http://www.bonniebiafore.com/, or email her at bonnie.biafore@gmail.com.




Tara Calishain is the editor of ResearchBuzz
(http://www.researchbuzz.com/), a weekly newsletter on Internet
searching and online information resources. She's also a regular
columnist for Searcher magazine. She's been writing about search engines
and searching since 1996; her recent books include Google Hacks
(O'Reilly) and Web Search Garage (O'Reilly).



Kevin Hemenway (http://www.disobey.com/), better known as Morbus Iff, is
the creator of Disobey.com, which bills itself as "content for the
discontented." Publisher, developer, and writer of more home cooking
than you could ever imagine (like the popular open sourced syndicated
reader AmphetaDesk, the best-kept gaming secret Gamegrene.com, the
popular Ghost Sites and Nonsense Network, 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 can get
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 on Yahoo! Mail.
In his spare time, he maintains the Yahoo! Java Search SDK.



Philipp Lenssen lives in Stuttgart, Germany, where he blogs about
Google, works as a programmer on an automobile web site, and eats spicy
Thai food with his girlfriend. He likes to ponder future technology and
jump on any technology bandwagon that seems worthwhile, especially all
the APIs that make a developer's life that much easier. Philipp's daily
musings can be found at http://blog.outer-court.com/.



Mikel Maron is an independent software developer and ecologist. He has
built several geographic-oriented projects around the worldKit mapping
package, including World as a Blog and mapufacture. Previously, he led
development of My Yahoo! in the pre-RSS days. Mikel was awarded a
master's degree from the University of Sussex for building a simulation
of the evolution of complexity in food webs. Originally from California,
Mikel is presently based mostly in Brighton, 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 currently taking a break after
cofounding and selling Covigna, a pioneer in Contract Lifecycle
Management.



Todd Ogasawara focuses on Mobile Workforce and Mobile Lifestyle
technology, paying special attention to the Microsoft Windows Mobile
platform (Pocket PC and Smartphone). Microsoft has recognized his
demonstrated practical 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 bring commercial (especially Microsoft-related) products
and GNU/Open Source software together in a synergistic and productive
way. Todd has written several articles about mobile devices, digital
cameras, and the Apple Mac Mini for the O'Reilly Network. He previously
worked as a technology analyst for GTE/Verizon. He also served as the
contracted forum manager for the MSN.com (and later ZDNet) Telephony
Forum and Windows CE Forum. More recently, he has served as the
eGovernment team leader for the State of Hawaii. You can find his Mobile
Workforce and Lifestyle commentary at http://www.mobileviews.com/. You
can learn more about Eccentric Technology at
http://www.ogasawalrus.com/. You can reach Todd by email at
Hacks@OgasaWalrus.com.



Mark Pilgrim is an accessibility architect by day. By night, he is a
husband and father who lives in North Carolina with his wife, 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 and cofounder and CTO of Catalyst Recruiting. He is author of
several 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 and has 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 your friends and are positively the
best trend on the Internet in years.
















Acknowledgments


To my wife, Shawnde, thanks for the continuous feedback and frontline
editing, and for cheerfully discussing Yahoo! during breakfast, 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.


Thanks to tech editor Steve Champeon for testing code, double-checking
facts, and adding important points to the technical details.


Thanks to Morbus Iff for taking my Perl to task and simplifying the
confusing bits.


Finally, thanks to everyone at Yahoo! who contributed tips and hack ideas,
including Vijay Anisetti, Stig Sæther Bakken, Dave Brown, Aurora Casanova,
David Dueblin, Jennifer Dulski, Marcus Foster, David Hall, Jason B.
Silverstein, Jeremy Zawodny, and many anonymous Yahoos. Thanks also to
Chris Kalaboukis and Bernard Mangold at Yahoo! Research for lending a
hand.
















Preface


Yahoo! is an impressive example of what can happen when a hobby takes on a
life of its own. In 1994, Jerry Yang and David Filo 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 the
basic 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 true computer geeks, they turned Yahoo! into
an acronym for Yet Another Hierarchical Officious Oracle.) Figure P-1 is a
look at the Yahoo! home page from December 1994.


Yahoo! looks very different today. Figure P-2 shows the more familiar
Yahoo! home page of 2005.


Though the two Yahoo! home pages look radically different, the original
idea of taming the chaos of the World Wide Web and making it accessible to
a wider audience remains. According to their 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! makes
and 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 the Web. Millions more use
Yahoo! Groups to share information and collaborate on projects. And still
more use Yahoo! Mail every day to stay in touch with friends, family, and
coworkers. And Yahoo! is continually adding products and features to
realize its vision.




Figure I-1. Yahoo! in 1994





Over the past year, the FUSE philosophy has been a distinct feature of
Yahoo!'s newest services. In February 2005, Yahoo! launched Yahoo! Web
Services, allowing outside developers to use, share, and expand Yahoo!
features. In March 2005, Yahoo! launched Yahoo! 360, a way for people to
share thoughts and information with friends and family, while expanding a
network of friends. In April 2005, Yahoo! introduced My Web, a way to save
and share search results while creating your own personal categorized
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 showing you examples of the many ways
people are expanding Yahoo! on their own. Though the hacks might be crude
and rude at times, they're written in the same spirit of sharing something
interesting that inspired the creation of Yahoo! in the first place.




Figure I-2. Yahoo! in 2005



















Why Yahoo! Hacks?


The term hacking has a bad reputation in the press. They use it to refer
to someone who breaks into systems or wreaks havoc with computers as their
weapon. Among people who write code, though, the term hack refers to a
quick-and-dirty solution to a problem, or a clever way to get something
done. And the term hacker is taken very much as a compliment, referring to
someone as being creative, having the technical chops to get things done.
The Hacks series is an attempt to reclaim the word, document the good ways
people are hacking, and pass the hacker ethic of creative participation on
to the uninitiated. Seeing how others approach systems and problems is
often the quickest way to learn about a new technology.


While Yahoo! itself has been around for over 10 years, it is releasing new
applications, web sites, and software at a blinding pace. 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 put out 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
at Yahoo!.
















How to Use This Book


You can read this book from cover to cover if you like, but each hack
stands on its own, so feel free to browse and jump to the different
sections that interest you most. If there's a prerequisite you need to
know about, a cross-reference will guide you to the right hack.


















How to Run the Hacks


The programmatic hacks in this book run either on the command line (that's
Terminal for Mac OS X folk, DOS command window for Windows users) or as
CGI (that's "common gateway interface") scriptsdynamic pages living on
your web site, accessed through your web browser.


Command-Line Scripts


Running a hack on the command line invariably involves the following
steps:



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 hacks online at
http://www.oreilly.com/catalog/yahoohks, where there is a ZIP archive
containing individual scripts saved as text files.



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 on your keyboard. In Unix…well, we'll just assume you know how to
get to the command line.



Navigate to where you saved the script at hand. This varies from
operating system to operating system, but usually involves something
like cd~/Desktop (that's your Desktop on the Mac).



Invoke the script by running the programming language's interpreter
(e.g., Perl) and feeding it the script (e.g., scriptname.pl) like so:


$ perl scriptname.pl




Most often, you'll also need to pass along some parametersyour search
query, the number of results you'd like, and so forth. Simply drop them
in after the script name, enclosing them in quotes if they're more than
one word or if they include an odd character or three:


$ perl scriptname.pl '"much ado about nothing" script' 10




The results of your script are almost always sent straight back to the
command-line window in which you're working, like so:


$ perl scriptname.pl '"much ado about nothing" script' 10
1. "Amazon.com: Books: Much Ado About Nothing: Screenplay…" [http://
www.amazon.com/exec/obidos/tg/detail/-/0393311112?v=glance]
2. "Much Ado About Nothing Script" [http://www.signal42.com/much_ado_
about_nothing_script.asp]







The elllpsis (…) bit signifies that we've cut off the output
for brevity's sake.






To stop output scrolling off your screen faster than you can read it, on
most systems you can pipe (read: redirect) the output to a little
program called more:


$ perl scriptname.pl | more




Hit the Enter/Return key on your keyboard to scroll through line by
line, or the space bar to leap through page by page.


You'll also sometimes want to direct output to a file for safekeeping,
importing into your spreadsheet application, or displaying on your web
site. This is as easy as:


$ perl scriptname.pl > output_filename.txt




And to pour some input into your script from a file, simply do the
opposite:


$ perl scriptname.pl < input_filename.txt




Don't worry if you can't remember all of this; each command-line hack has
a "Running the Hack" section that shows you just how it's done.


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 scripts as those run on the
command line, they are more troublesome because setups vary so widely. You
might be running your own server, your web site might be hosted on an
Internet service provider's (ISP's) server, your content might live 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, or call the ISP's
technical support department, or ask your local system administrator for
help.


Generally, though, the methodology is the same:



Type the program in to 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.cgi (the cgi bit
reveals that you're dealing with a CGI script).


Alternately, you can download the code for all of the hacks online at
http://www.oreilly.com/catalog/yahoohks, where there is a ZIP archive
containing individual scripts saved as text files.



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 is where a CGI script must usually live in order for the
server to run the script (rather than just displaying the script's text
in your web browser) when you visit its URL.



You usually need to "bless" CGI scripts as executableto be run rather
than displayed. Just how you do this depends on the operating system of
your server. If you're on a Unix/Linux or Mac OS X system, this usually
entails typing the following on the command line:


$ chmod 755 scriptname.cgi





Now you should be able to point your web browser at the script and have
it run as expected, behaving in a manner similar 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 http://www.your_domain.com/cgi-bin/scriptname.cgi,
where your_domain.com is your web site domain, cgi-bin refers to the
directory in which your CGI scripts live, and scriptname.cgi is the
script itself.


If you don't have your own domain and are hosted at an ISP, the URL is
more likely to look like
http://www.your_isp.com/~your_username/cgi-bin/scriptname.cgi, where
your_isp.com is your ISP's domain, ~your_username is your username at
the ISP, cgi-bin refers to the directory in which your CGI scripts live,
and scriptname.cgi is the script itself.


If you come up with something called an "internal server error" or see the
error code 500, something's gone wrong somewhere in the process. At this
point you can take a crack at debugging (read: shaking the bugs out)
yourself or ask your ISP or system administrator for help.
Debuggingespecially CGI debuggingcan be a little more than the average
newbie can bear, but there is help 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


Fancy trying your hand at a spot of programming? O'Reilly's best-selling
Learning Perl (http://www.oreilly.com/catalog/lperl3), by Randal L.
Schwartz and Tom Phoenix, provides a good start. Apply what you learn to
understanding and using the hacks in this book, perhaps even taking on the
"Hacking the Hack" sections to tweak and fiddle with the scripts. This is
a useful way to get a little programming under your belt if you're a
searching nut, since it's always a little easier to learn how to program
when you have a task to accomplish and existing code to leaf through.
















How This Book Is Organized


The book is divided into several chapters, organized by subject:




Chapter 1, Search


This chapter shows you how to become a Yahoo! power searcher by taking
advantage of meta keywords to return more relevant results. You'll also
see how to use search shortcuts to find instant answers to some common
questions. This chapter tells you how to find popular search phrases and
technologies by analyzing Yahoo! Buzz, and we'll pit Yahoo! against Google
to see which search engine returns the most relevant results.




Chapter 2, Services


Yahoo! offers information about everything from stocks and bonds to movie
and TV schedules. This chapter shows some unique ways to use Yahoo! Web
Services, including monitoring your commute for problems, watching TV
schedules automatically for appearances by your favorite celebrities, 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 social networks with Yahoo! 360. This chapter also shows
some ways to personalize Yahoo! Messenger and share your photos with the
world.




Chapter 4, Web Services


This chapter introduces you to the back door that Yahoo! has opened for
developers. You'll find bare-bones examples in several scripting languages
that can give you a head start to creating your own Yahoo!-powered
applications.




Chapter 5, Applications


See how people are using Yahoo! data in their own applications and have a
bit of fun in the process. Find out how to randomize your desktop
background with images from across the Web and how to integrate Yahoo!
with Excel and Outlook.




Chapter 6, Webmastering


If you publish on the Web, you're well aware of the traffic Yahoo! can
send to your site. This chapter shows how to get listed and introduces you
to other Yahoo! components you can plug into your site.















Conventions Used in This Book


The following is a list of the typographical conventions used in this
book:




Italics


Used to indicate URLs, filenames, filename extensions, and directory
names. For example, a path in the filesystem will appear as
/Developer/Applications.




Constant width


Used to show code examples, the contents of files, and console output, as
well as the names of variables, commands, and other code excerpts.




Constant width bold


Used to highlight portions of code, typically new additions to old code.
Also used to show text you should type literally at a command-line prompt.




Constant width italic


Used in code examples and other excerpts to show sample text to be
replaced with your own values.




Gray type


Used to indicate a cross-reference within the text.



A carriage return () at the end of a line of code is used to denote an
unnatural line break; that is, you should not enter these as two lines of
code, but as one continuous line. Multiple lines are used in these cases
due to page-width constraints.


You should pay special attention to notes set apart from the text 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 the relative
complexity of the hack:


beginner moderate expert















Using Code Examples


This book is here to help you get your job done. In general, you may use
the code in this book in your programs and documentation. You do not need
to contact us for permission unless you're reproducing a significant
portion of the code. For example, writing a program that uses several
chunks of code from 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 book and 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 attribution usually
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 or the
permission given above, feel free to contact us at
permissions@oreilly.com.
















Safari Enabled


When you see a Safari® Enabled icon on the cover of your favorite
technology book, that means the book is available online through the
O'Reilly Network Safari Bookshelf.


Safari offers a solution that's better than e-books. It's a virtual
library that lets you easily search thousands of top tech books, cut and
paste code samples, download chapters, and find quick answers when you
need the most accurate, current information. Try it for free at
http://safari.oreilly.com/.



















How to Contact Us


We have tested and verified the information in this book to the best 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 us your feedback. Please let us know about any
errors, inaccuracies, bugs, misleading or confusing statements, and typos
that you find anywhere in this book.


Please also let us know what we can do to make this book more useful to
you. We take your comments seriously and will try to incorporate
reasonable suggestions into future editions. You can write to us at:
O'Reilly Media, Inc.1005 Gravenstein Hwy N.Sebastopol, CA 95472(800)
998-9938 (in the U.S. or Canada)(707) 829-0515 (international/local)(707)
829-0104 (fax)


To ask technical questions or to comment on the book, send email to:
bookquestions@oreilly.com


The web site for Yahoo! Hacks lists examples, errata, and plans for future
editions. You can find this page at:
http://www.oreilly.com/catalog/yahoohks


For more information about this book and others, see the O'Reilly web
site:
http://www.oreilly.com/















Got a Hack?


To explore Hacks books online or to contribute a hack for future titles,
visit:
http://hacks.oreilly.com/















Chapter 1. Search


Section 1.1. Hacks 122: Introduction


Hack 1. Fine-Tune Yahoo! Web Search Queries


Hack 2. Save Time with Search Shortcuts


Hack 3. Create a Yahoo! ID


Hack 4. Set Persistent Yahoo! Search Preferences


Hack 5. Assemble Advanced Search Queries


Hack 6. Translate Any Page with Yahoo!


Hack 7. Personalize, Track, and Share the Web


Hack 8. Prefetch Yahoo! Search Results


Hack 9. Compare Yahoo! and Google Search Results


Hack 10. Find Content You Can Reuse Legally


Hack 11. Find Video from Across the Web


Hack 12. Streamline Browsing with the Yahoo! Toolbar


Hack 13. Customize the Firefox Quick Search Box


Hack 14. Spot Trends with Yahoo! Buzz


Hack 15. Find Hot Technologies at the Buzz Game


Hack 16. Tame Long Yahoo! URLs


Hack 17. Opt Out of Advertiser Cookies


Hack 18. Track News About Yahoo!


Hack 19. Spider the Yahoo! Catalog


Hack 20. Browse the Yahoo! Directory


Hack 21. Track Additions to Yahoo!


Hack 22. Yahoo! Directory Mindshare in Google
















1.1. Hacks 122: Introduction


Many 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 signs themselves 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! Web Search results page, you might find new ways to reach your
destination.


Take a look at Figure 1-1, which shows a Yahoo! Web Search results page
for the query ancient greece.




Figure 1-1. Yahoo! Web Search results





You can see the familiar numbered listing of search results, but there are
a number of other bits of information on the page. Here's a look at what's
available on a Yahoo! Search results page:




Navigation bar


You'll find the gray navigation bar at the top of the page on many pages
at Yahoo! sites. The bar provides a consistent way 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 indicates your 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 of the 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], and Yahoo! Shopping [Hack #47]. You can click any
of these search links to search with the exact query you used at one of
the other Yahoo! Search properties so that you don't have to retype your
search term.




Result count


Search results are returned as a number of pages, and you'll find your
position within the results in the shaded blue bar. For instance, the
first page of results will be labeled as Results 110, the second page will
show Results 1120, and so on. (You can adjust the number of results per
page by setting your search preferences [Hack #4].) You'll also see the
estimated total number of results for your query.




Query definition links


Just to the right of the result count, you'll see the words in the query
as links. You can click the links to see dictionary definitions of the
words at Yahoo! Reference [Hack #40].




Search speed


The shaded blue bar will also show you how long it took to fetch the
results, usually less than a half-second.




Sponsor results


You'll find context-sensitive advertising along the right side of the page
and in a shaded blue box above or below the Yahoo! Web Search results.
Advertising is always clearly labeled Sponsor Results, and the type of ads
will be triggered by the topic you're searching for.




Search suggestions


Search phrases similar to the one you entered are labeled with Also Try:
at the top of the page. These suggestions show you what other Yahoo! users
are searching for related to your topic and can help you refine your
search. Yahoo! will display the top few suggestions, and if there are
several suggestions you can click the More or Show All links to see a
complete list of suggestions available.




Yahoo! shortcut info


If your query triggered a Yahoo! Shortcut [Hack #2], the shortcut info
will be shown above the Web results and marked with the Y! logo. Shortcuts
usually give you brief information about your query, with links to more
information at other Yahoo! properties.




Web results


The Web Search results show the familiar list of documents from across the
Web, which contain your query words or phrases. Each result is numbered
and includes the document title, a brief excerpt with query words in bold,
and the document location.




Results page


Below the Web Search results you can navigate between results pages by
clicking a page number or the Prev and Next links.


Each Yahoo! Web Search result represents a document somewhere on the Web.
The document will most likely be a web page written in HTML, but could be
in another format such as Adobe PDF, Microsoft Word, or plain text. Figure
1-2 shows a typical Yahoo! Web Search result with all of the associated
links and features.




Figure 1-2. A single Yahoo! Web Search result





A closer look at a Web Search result shows that there's more listed than
simply a document title and excerpt. Here's a look at what you'll find
with each result:




Document title


The document title is pulled from the document itself, either from HTML
tags within the document or from the first few words in the <br /> document. Click the title to view the page or document.<br /><br /><br /><br /><br /> New window link<br /><br /><br /> To the right of the title is an icon showing two windows that you can <br /> click to open the document in a new browser window. This option is handy <br /> for keeping your search results in place while you read through pages of <br /> the results in different windows.<br /><br /><br /><br /><br /> Document excerpt<br /><br /><br /> Just below the title, you'll find an excerpt of text from the document <br /> with words or phrases from your query in bold. This helps you determine <br /> the context of your search phrase and can tell you quickly whether the <br /> document is relevant.<br /><br /><br /><br /><br /> Category<br /><br /><br /> If the document or page is listed in the Yahoo! Directory, you'll see the <br /> category that page is listed in. You can click the category title to see <br /> that category and view other sites that Yahoo! Editors have chosen to <br /> include in the directory.<br /><br /><br /><br /><br /> RSS<br /><br /><br /> Many web publishers associate an RSS feed with their sites, which allows <br /> readers to subscribe to site updates in programs called Newsreaders or at <br /> sites such as My Yahoo! that pull content from other sources. When Yahoo! <br /> detects the presence of a site feed, you'll find a link to view that feed <br /> as raw XML or add the feed to My Yahoo! with a click.<br /><br /><br /><br /><br /> URL<br /><br /><br /> On the last line of the listing, you'll see the document URL in green with <br /> any words from your query in bold. This tells you the domain the document <br /> is hosted under, and you can tell from the top-level domain (.com, .edu, <br /> .gov, etc.) whether the site is run by a business, a school, or the U.S. <br /> government.<br /><br /><br /><br /><br /> Size in bytes<br /><br /><br /> Many results (such as those listed earlier in Figure 1-1) show the size of <br /> the document in bytes, which can give you a rough idea of how long the <br /> page will take to download. Web pages are usually fairly quick, but <br /> Microsoft Word documents or Adobe PDF files might vary widely in size.<br /><br /><br /><br /><br /> Cache<br /><br /><br /> If Yahoo! has a copy of the document saved on its servers, you can click <br /> the Cached link to view the copy. This is particularly useful if the site <br /> isn't responding, as you can still get to an archived copy of the <br /> information.<br /><br /><br /><br /><br /> Other pages<br /><br /><br /> The "More from this site" link will show you other pages at the domain <br /> that match your query.<br /><br /><br /><br /><br /> My Web links<br /><br /><br /> Yahoo!'s My Web [Hack #7] lets you save sites that you want to remember, <br /> or block sites that you never want to see in results again. You can use <br /> the Save and Block links to add or remove documents.<br /><br /><br /> Once you're aware of all the features of the Yahoo! Web Search results <br /> page, you can make decisions about the best path to the information you're <br /> after.<br /><br /><br /> This chapter shows you how to take advantage of Yahoo! Web Search in a <br /> number of different waysfrom using meta keywords for quick answers [Hack <br /> #1] to viewing results in a radically different way [Hack #77].<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 1. Fine-Tune Yahoo! Web Search Queries<br /><br /><br /><br /><br /><br /> By understanding how to phrase your searches, you'll find more relevant <br /> search results.<br /><br /><br /> Using Yahoo! Web Search (http://search.yahoo.com/) is deceptively simple. <br /> You can type in any word or phrase and find matches in documents across <br /> the Web. The trade-off for this simplicity is having to look through <br /> hundreds, thousands, or millions of results to find the documents that are <br /> actually useful to you. By understanding how Yahoo! expects queries to be <br /> phrased, you can limit the results to include only those documents most <br /> relevant to yousaving you the time of looking through extraneous results.<br /><br /><br /> 1.2.1. Search Basics<br /><br /><br /> To start building sophisticated queries, you need to know the basics. The <br /> following search basics will help you refine your Yahoo! searches:<br /><br /><br /><br /><br /> Keyword<br /><br /><br /> By default, Yahoo! searches for all of the words you type into a search <br /> form. If you type grammar into the search form, Yahoo! will return <br /> documents that contain the word grammar. A search for grammar school will <br /> return documents that contain both words somewhere within the document, <br /> but not necessarily together.<br /><br /><br /><br /><br /> Complete phrase<br /><br /><br /> To search for words in a specific order, enclose the words in quotation <br /> marks. A search for "grammar school" will return documents that contain <br /> the complete phrase grammar school. You can combine keyword and phrase <br /> searches. To find documents that contain the phrase grammar school and <br /> also have the word Oregon somewhere in the document, you could search for <br /> "grammar school" Oregon.<br /><br /><br /><br /><br /> OR keyword<br /><br /><br /> You can change the default behavior of keyword searches by using the <br /> capitalized keyword OR between words. A search for grammar OR primary will <br /> return documents that contain either grammar or primary, but not <br /> necessarily both words.<br /><br /><br /><br /><br /> Exclude words or phrases<br /><br /><br /> To find documents without a certain word, you can use the minus sign (-) <br /> along with the word you want to exclude. If a search for Oregon school <br /> returns too many pages for schools in the city of Portland, you could type <br /> Oregon school -Portland to exclude any pages with the word Portland from <br /> the results.<br /><br /><br /> Once you have the basics down, you can start mixing and matching, and <br /> grouping queries together with parentheses. To find documents that contain <br /> the word Oregon, and the phrase grammar school or the phrase elementary <br /> school, you could type Oregon ("grammar school" OR "elementary school"). <br /> The parentheses are required to show where the OR should be used. Without <br /> the parentheses, Yahoo! would look for documents that contain both the <br /> word Oregon and the phrase grammar school, or documents that simply <br /> contain the phrase elementary school. Because the word Oregon is necessary <br /> across documents, the two secondary phrases need to be grouped into a <br /> single unit with parentheses.<br /><br /><br /> 1.2.2. Search Meta Words<br /><br /><br /> In addition to the basic operators, there are keywords that Yahoo! calls <br /> Search Meta Words that you can use to refine your search:<br /><br /><br /><br /><br /> site:<br /><br /><br /> Use this keyword to limit search results to a single web site. You can <br /> search for the word marsz across NASA sites by typing mars site:nasa.gov. <br /> All of the results will be from sites hosted at the nasa.gov domain. You <br /> also use this keyword to limit results to a single top-level domain, such <br /> as .org, .com, or .edu. To find mentions of the word mars across academic <br /> sites, type mars site:.edu.<br /><br /><br /><br /><br /> hostname:<br /><br /><br /> This keyword limits results to a specific host at a site. For example, <br /> NASA's Mars Exploration Program has a web site at <br /> http://mars.jpl.nasa.gov/. If you want to search this specific section of <br /> the nasa.gov domain for the word rover, you could type rover <br /> hostname:mars.jpl.nasa.gov.<br /><br /><br /><br /><br /> link:<br /><br /><br /> You can use this keyword to find sites that link to a specific URL. This <br /> keyword works well if you want to judge the popularity of a specific page <br /> by finding the number of other sites linking to a particular page. You'll <br /> need to include the full URL, so to find pages that link to the Amazon <br /> Hacks page at the O'Reilly Hacks site, type <br /> link:http://www.oreilly.com/catalog/amazonhks/.<br /><br /><br /><br /><br /> linkdomain:<br /><br /><br /> Instead of a specific page, this keyword looks for any links to a specific <br /> domain. If you're interested in pages that link to <br /> http://www.oreilly.com/, type linkdomain:oreilly.com.<br /><br /><br /><br /><br /> url:<br /><br /><br /> This keyword lets you look up a single page at Yahoo! by specifying the <br /> URL. You can look up the O'Reilly Hacks home page by typing <br /> url:http://hacks.oreilly.com/. You could use this keyword to see how pages <br /> at a site are displayed in Yahoo!'s Web, Images, and Video Search results.<br /><br /><br /><br /><br /> inurl:<br /><br /><br /> Use this keyword to find sites that have a specific word within the URL. <br /> To find all sites that have the word mars in the URL, type inurl:mars.<br /><br /><br /><br /><br /> intitle:<br /><br /><br /> Like inurl:, this keyword returns documents that have a specific word in <br /> the document title. To find documents with mars in the title, use <br /> intitle:mars.<br /><br /><br /> You can also use the basic search operators in combination with the Search <br /> Meta Words to refine your search. Say you'd like to search for the word <br /> mars across documents, but you don't want pages from any nasa.gov site; <br /> type mars -site:nasa.gov. Because Yahoo! supports very long queries, you <br /> could specify a whole list of sites that you don't want information from: <br /> mars -site:nasa.gov -site:mars.com -site:space.com. But to search those <br /> sites exclusively, take away the minus symbol, group the site list <br /> together with parentheses, and use the OR keyword like this: mars <br /> (site:nasa.gov OR site:mars.com OR site:space.com). Again, note that the <br /> use of the OR keyword requires the use of parentheses.<br /><br /><br /> Some of these query combinations can also be accomplished with the <br /> advanced search form [Hack #5] available at <br /> http://search.yahoo.com/web/advanced.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 2. Save Time with Search Shortcuts<br /><br /><br /><br /><br /><br /> By using a few specific keywords, you can have Yahoo! answer common <br /> questions within your search results, provide specific information, or <br /> point directly to your answer.<br /><br /><br /> At its most basic, Yahoo! Search allows you to type in search terms, click <br /> the Search button, and receive documents that include that word or phrase <br /> from across the Web. This makes Yahoo! a keyword search engine, and <br /> knowing this can help you put together your queries.<br /><br /><br /> Yahoo! Search accepts a number of key phrases that can provide quick <br /> answers to common questions. To illustrate, here's an example in which <br /> search shortcuts can give you a faster answer than keywords alone.<br /><br /><br /> Imagine you're in California and you'd like to call a friend in London, <br /> England. You can't remember the time difference and you don't want to call <br /> at 3 a.m. London time, so you turn to Yahoo! for help. Browsing to <br /> http://search.yahoo.com/, you find yourself in front of the search form, <br /> about to type. What's the best query? If you were asking a human being for <br /> the answer you might be tempted to type in a complete question: what is <br /> the time in London?.<br /><br /><br /> Because Yahoo! Search looks for matching words or phrases, you've told <br /> Yahoo! to find documents that include the words in your phrase. So the top <br /> results will likely be the web site for the London newspaper The Times and <br /> other documents that contain the search terms London and time. You'll <br /> probably find your answer at sites that are in the results, but there's a <br /> much faster way to tell Yahoo! Search exactly what you're looking for. <br /> Understanding the time zone and other search shortcuts will give you quick <br /> answers to some common questions.<br /><br /><br /> 1.3.1. Yahoo! Search Shortcuts<br /><br /><br /> When Yahoo! Search encounters a key phrase, Yahoo! tries to provide a <br /> direct answer, in addition to matching documents that include the terms in <br /> the phrase. For example, if you want to know the current time in London, <br /> you can type time in London and you'll find the current time in London <br /> above the search results, as shown in Figure 1-3.<br /><br /><br /><br /><br /> Figure 1-3. An answer using a Yahoo! Search shortcut<br /><br /><br /><br /><br /><br /> By using this shortcut, you'll have the answer without looking through the <br /> results or visiting other sites. Replace London with any city or with a <br /> city-and-state combination, and you'll never have to worry about <br /> calculating time zone differences again.<br /><br /><br /> You'll know you've used a Yahoo! shortcut when you see a result at the top <br /> marked with the Yahoo! Y!, as shown in Figure 1-3. You can browse a <br /> complete, updated list of Yahoo! Search shortcuts at <br /> http://tools.search.yahoo.com/shortcuts/. Here are a few of the shortcuts <br /> available:<br /><br /><br /><br /><br /> Definitions<br /><br /><br /> Type define word, and Yahoo! will provide a brief dictionary definition <br /> for the word and a link to the full dictionary entry for that word at <br /> Yahoo! Reference [Hack #40].<br /><br /><br /><br /><br /> Encyclopedia entries<br /><br /><br /> Search for word facts, and Yahoo! will display an excerpt of the Columbia <br /> Encyclopedia entry for that word and a link to the full entry.<br /><br /><br /><br /><br /> Airport information<br /><br /><br /> Yahoo! provides quick links to maps, flight information, and local weather <br /> if you type airport code airport. For example, the shortcut for San <br /> Francisco International Airport is SFO airport.<br /><br /><br /><br /><br /> Hotels<br /><br /><br /> Type city hotels to get a quick list of hotels in that city, along with <br /> the Yahoo! Local rating, the base rate, and a link to check availability. <br /> You can also look for a specific hotel chain by typing city chainfor <br /> example, San Francisco Ramada.<br /><br /><br /><br /><br /> Stock quotes<br /><br /><br /> Type quote stock symbol to get the current trading price for a stock <br /> (delayed 15 minutes). You can keep tabs on Yahoo! by typing quote yhoo.<br /><br /><br /><br /><br /> Sports scores<br /><br /><br /> Find out how your favorite pro team is doing by typing team-mascot scores. <br /> You'll get a quick look at recent games, and sometimes you can see who <br /> they're playing in the next game. The query 49ers scores will give you <br /> information about the San Francisco 49ers football team.<br /><br /><br /><br /><br /> Movie showtimes<br /><br /><br /> To see when movies are playing in your area, type showtimes Zip Code and <br /> you'll get links to local theater showtimes and a few showtimes for <br /> current movies.<br /><br /><br /><br /><br /> Zip Codes<br /><br /><br /> You can find all of the Zip Codes for a city by typing zip code city.<br /><br /><br /><br /><br /> Area codes<br /><br /><br /> If you're not sure where someone is calling from, try typing the <br /> three-digit area code into Yahoo! Search. Yahoo! will return a list of <br /> cities in that area code.<br /><br /><br /><br /><br /> Weather<br /><br /><br /> For a quick look at the current weather for any city, type city weather. <br /> Yahoo! will give you the current conditions and the expected high and low <br /> temperatures.<br /><br /><br /> Once you learn how to speak the Yahoo! Search shortcut language, you'll <br /> save time answering some basic questions.<br /><br /><br /> 1.3.2. Yahoo! Properties Shortcuts<br /><br /><br /> Another set of shortcuts available via Yahoo! Search forms are shortcuts <br /> to Yahoo! properties. Say you want to get to Yahoo! Movies but can't <br /> remember the URL. You can simply type movies! into any search form, and <br /> you'll automatically be redirected to Yahoo! Movies <br /> (http://movies.yahoo.com/).<br /><br /><br /> The exclamation point at the end lets Yahoo! know you're looking for a <br /> Yahoo! property.<br /><br /><br /> There are hundreds of Yahoo! properties, and most of the shortcuts are <br /> intuitive. Here's a list of a few Yahoo! properties, along with their URLs <br /> and shortcuts:<br /><br /><br /> Table 1-1. <br /><br /><br /> Property<br /><br /> URL<br /><br /> Shortcut<br /><br /><br /> Yahoo! Mail<br /><br /> http://mail.yahoo.com/<br /><br /> mail!<br /><br /><br /> Yahoo! Games<br /><br /> http://games.yahoo.com/<br /><br /> games!<br /><br /><br /> Yahoo! News<br /><br /> http://news.yahoo.com/<br /><br /> news!<br /><br /><br /> Yahoo! Sports<br /><br /> http://sports.yahoo.com/<br /><br /> sports!<br /><br /><br /> Yahoo! Finance<br /><br /> http://finance.yahoo.com/<br /><br /> finance!<br /><br /><br /> Yahoo! Address Book<br /><br /> http://address.yahoo.com/<br /><br /> address!<br /><br /><br /> Yahoo! Calendar<br /><br /> http://calendar.yahoo.com/<br /><br /> calendar!<br /><br /><br /> Yahoo! Education<br /><br /> http://education.yahoo.com/<br /><br /> education!<br /><br /><br /> Yahoo! Next<br /><br /> http://next.yahoo.com/<br /><br /> next!<br /><br /><br /><br /><br /><br /> Keep in mind that you can use these Yahoo! properties shortcuts from any <br /> Yahoo! Search form, including the Yahoo! Toolbar form and the Firefox <br /> quick search box.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 3. Create a Yahoo! ID<br /><br /><br /><br /><br /><br /> The key to many of the services at Yahoo! is a unique Yahoo! ID, and <br /> understanding how IDs work is key to keeping your Yahoo! ID private.<br /><br /><br /> A Yahoo! ID is what distinguishes you from the crowd and what lets Yahoo! <br /> remember you across browsing sessions and across computers. If you've been <br /> using the Web for any amount of time, chances are good that you already <br /> have a Yahoo! ID. In November 2004, Nielsen/Netratings estimated that 55 <br /> million people around the world use Yahoo! Mail, and all of them sign in <br /> with a Yahoo! ID.<br /><br /><br /> 1.4.1. Signing Up<br /><br /><br /> If you don't already have a Yahoo! ID, you can create one in less than <br /> five minutes. Browse to http://login.yahoo.com/ and click Sign Up Now for <br /> the new account form.<br /><br /><br /> The most important decision to make as you fill out the new account form <br /> is what your Yahoo! ID will be. You'll use your ID anytime you want to <br /> access your personalized Yahoo! data, and your ID will determine what your <br /> Yahoo! Mail email address will be. If your Yahoo! ID is j0d00d, your email <br /> address is j0d00d@yahoo.com. The hardest part is finding an ID that is <br /> different from the 55 million Yahoo! IDs that already exist. The next <br /> hardest part is keeping the ID short and memorable. Keep in mind that <br /> you'll use this ID anytime you want to log in to Yahoo!. A short ID will <br /> save your fingers some work if you plan to log in to Yahoo! from your cell <br /> phone. And friends might want to contact you with Yahoo! Instant Messenger <br /> via your Yahoo! ID, so a short ID that is similar to your name will help <br /> them remember it.<br /><br /><br /> Before filling out the form, go straight to the Yahoo! ID field and start <br /> trying potential IDs. Click the Check Availability of This ID button until <br /> you find something that's not taken. If you can get something with your <br /> initials or first and last name, consider yourself lucky.<br /><br /><br /> When it's time to choose your password, it's tempting to recycle a <br /> password that you use in other places. Your Yahoo! ID and password is the <br /> only thing protecting your email from unauthorized readers, so it's a good <br /> idea to make the password unique and somewhat complex. Yahoo! requires at <br /> least six characters, but you can do better than that. A complex password <br /> should include upper-and lowercase letters, as well as symbols or numbers. <br /> A good trick for creating long, memorable passwords that are hard for <br /> hackers to guess is to think of the first line of your favorite poem or <br /> song and choose the first letter of each word as your password. So "Mary <br /> had a little lamb, its fleece was white as snow" would translate into the <br /> password Mhallifwwas. Add a memorable number, such as the year you were <br /> born, to the end and you'll have something like Mhallifwwas1973, which <br /> looks completely random but has meaning for you.<br /><br /><br /><br /><br /> If you find yourself keeping track of several dozen unique <br /> passwords, you might want to consider using a password manager <br /> to store them securely in one place. You can download the <br /> freely available Password Safe program for Windows at <br /> http://passwordsafe.sourceforge.net/just be sure not to forget <br /> the master password! Mac and Linux users may want to try <br /> Password Gorilla, available at <br /> http://www.fpx.de/fp/Software/Gorilla/.<br /><br /><br /><br /><br /><br /><br /> If you ever forget your Yahoo! password, you can always reset it later, in <br /> a couple of different ways. If you provide an alternate email address <br /> during this process, you'll be able to verify that address and have the <br /> ability to reset your password at any time. But if you want a bit more <br /> anonymity and don't want to provide an alternate email, be sure to <br /> remember the answer you give to the security question when you sign up. <br /> Your answer will be your only key to recovering your password and any <br /> information associated with your account if you ever forget your password.<br /><br /><br /> As you're finishing up the registration process, you'll notice an image <br /> with wavy numbers and letters, like the one in Figure 1-4.<br /><br /><br /><br /><br /> Figure 1-4. Yahoo! Registration captcha equal to "6z3e"<br /><br /><br /><br /><br /><br /> The image is called a captcha, and Yahoo! uses them to keep spammers from <br /> automatically creating Yahoo! accounts. If you can discern the numbers and <br /> letters in the graphic, you will prove to Yahoo! that you are a human <br /> rather than an automated program. The captcha can be difficult to read <br /> sometimes, and if you can't make out the letters and numbers, it doesn't <br /> mean you're not a human. Simply reload the page to get a differentand <br /> hopefully more readablecaptcha.<br /><br /><br /> 1.4.2. Signing In<br /><br /><br /> If you just created your account, you'll be logged in and ready to use any <br /> of Yahoo!'s applications. But from time to time, you'll need to sign in. <br /> Again, your Yahoo! ID and password are your keys to security, so you <br /> should do what you can to protect these. Before you log in, you can <br /> protect this information by switching to a secure connection, as follows.<br /><br /><br /> Underneath the login form, you'll find a text link labeled MODE:, which <br /> you can use to switch to a secure connection. Clicking the link, you'll <br /> find that the URL in the address bar begins with https: instead of the <br /> standard http: and you'll see a padlock icon in the lower status bar, as <br /> shown in Figure 1-5.<br /><br /><br /><br /><br /> Firefox users will have the added indication of a yellow <br /> address bar when browsing a secure page.<br /><br /><br /><br /><br /><br /><br /> The default login form uses a standard connection, and making this small <br /> switch to the secure SSL connection will ensure that your Yahoo! ID and <br /> password combination are hidden from prying eyes. But it's important to <br /> note that the rest of your Yahoo! activities will not be encrypted, even <br /> if you log in securely. Yahoo! uses a standard connection for most of its <br /> services, including email. If you're ever wondering whether the current <br /> page you're visiting is secure, check for the padlock icon in the <br /> lower-right corner of your browser.<br /><br /><br /><br /><br /> Figure 1-5. Yahoo! secure login page<br /><br /><br /><br /><br /><br /> Checking the "Remember my ID on this computer" box sets a cookie in your <br /> browser that lets Yahoo! remember your ID between browsing sessions. Even <br /> with this option checked, Yahoo! will occasionally ask you to verify your <br /> password, so keep it handy if you don't have your password memorized. If <br /> you change your mind and no longer want Yahoo! to remember your ID on your <br /> computer, you can simply sign out.<br /><br /><br /> 1.4.3. Signing Out<br /><br /><br /> At the top of most pages at Yahoo!, you'll find a welcome message that <br /> includes your Yahoo! ID, as shown in Figure 1-6.<br /><br /><br /><br /><br /> Figure 1-6. Welcome message with Sign Out link<br /><br /><br /><br /><br /><br /> Under your ID, you'll find a Sign Out link that you can click anytime to <br /> sign out of Yahoo! If you share your computer with others or visit Yahoo! <br /> from a public computer, it's always a good idea to sign out when you're <br /> done using Yahoo!. Signing out will help ensure that your personal <br /> dataeverything from financial information to private emailstays personal.<br /><br /><br /> 1.4.4. Removing Your Account<br /><br /><br /> If you ever want to part ways with Yahoo!, you can visit <br /> https://edit.yahoo.com/config/delete_user to remove your account <br /> completely. You'll permanently lose access to any personal data you may <br /> have assembled (such as email) and any personal preferences (such as news <br /> sources at My Yahoo!). Weigh this option carefully before proceeding, <br /> because it's a permanent change, and you won't be able to recover your <br /> unique Yahoo! ID in the future. You'll need to enter your password a final <br /> time on this page and then click "Terminate this account."<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 4. Set Persistent Yahoo! Search Preferences<br /><br /><br /><br /><br /><br /> Tweak your Yahoo! preferences to get the most out of your searching.<br /><br /><br /> If you already have a Yahoo! ID, you can set some preferences that will <br /> affect the appearance and content of your Yahoo! searches. To set your <br /> preferences, first make sure you're logged in to Yahoo! by visiting <br /> http://login.yahoo.com/ and entering your Yahoo! ID and password. From <br /> there, browse to http://www.yahoo.com/ or http://search.yahoo.com/ and <br /> look for the Preferences link to the right of the search form, like the <br /> one highlighted in Figure 1-7.<br /><br /><br /><br /><br /> Figure 1-7. Yahoo! Search Preferences link<br /><br /><br /><br /><br /><br /> If you don't see the preferences link, you can browse directly to <br /> http://search.yahoo.com/preferences. From the Preferences page, you can <br /> set a number of options that Yahoo! will remember and apply to any search <br /> results in the future.<br /><br /><br /> 1.5.1. New Window<br /><br /><br /> When searching a particular topic, it's easy to click on a search result, <br /> get lost in reading, and find yourself several clicks away from your <br /> original page of search results. If you find yourself clicking your <br /> browser's Back button again and again to get back to your Yahoo! search <br /> results, you might want to open links from the search results page in a <br /> new browser window. You can set this preference by checking the New Window <br /> box on the Preferences page. This is handy for keeping your search results <br /> page in place, allowing you to browse other sites without fear of losing <br /> your search results.<br /><br /><br /> 1.5.2. Number of Results<br /><br /><br /> By default, Yahoo! shows 20 results on each page. You can change this <br /> setting on the Preferences page to 10, 15, 20, 30, 40, or 100 results. <br /> Setting it to display fewer results per page will keep your scrolling to a <br /> minimum, but if you have a large screen you might appreciate seeing up to <br /> a hundred results without clicking through several pages.<br /><br /><br /> 1.5.3. Adult Content Filtering<br /><br /><br /> As in other media, the Web is filled with material that isn't appropriate <br /> for children or the workplace. Yahoo! indexes the entire Webincluding the <br /> seamier sectionsand Yahoo!'s answer to this dilemma is the SafeSearch <br /> Filter. With SafeSearch enabled, Yahoo! will do its best to exclude any <br /> adult material from search results. There are three different settings you <br /> can apply to your Yahoo! ID:<br /><br /><br /><br /><br /> Filter out adult Web, video, and image search results<br /><br /><br /> This enables SafeSearch across every type of Yahoo! Search that has adult <br /> content.<br /><br /><br /><br /><br /> Filter out adult video and image search results only<br /><br /><br /> This enables SafeSearch for video and image searches at Yahoo!, but Web <br /> searches might still contain adult material.<br /><br /><br /><br /><br /> Do not filter results<br /><br /><br /> This setting completely disables SafeSearch, and adult material will be <br /> included in Yahoo! Search results.<br /><br /><br /> The default setting is "Filter video and image search," so even if you <br /> never visit your Yahoo! Preferences page, SafeSearch is working behind the <br /> scenes.<br /><br /><br /> In addition to choosing a filter level, you can lock a SafeSearch setting <br /> for a specific browser. When you check the SafeSearch Lock checkbox and <br /> update your preferences, Yahoo! sets a cookie for your browser that will <br /> keep your SafeSearch setting for every Yahoo! ID that uses that browser. <br /> If you have children in the house and they share your web browser, this is <br /> a way to keep adult material from them.<br /><br /><br /> Because the SafeSearch Lock is tied to a particular browser rather than a <br /> particular Yahoo! ID, it functions a bit differently from the other <br /> settings. If another user logs in with a different Yahoo! ID using the <br /> same browser, she'll be able to change the SafeSearch Lock setting. <br /> However, if the particular Yahoo! ID has an age set and the user is listed <br /> as under 18, the SafeSearch Lock option will be hidden from view.<br /><br /><br /> 1.5.4. Language<br /><br /><br /> Yahoo! keeps track of files and web pages on servers across the world and <br /> notes the language of each page in its index. You can specify that you'd <br /> like to receive results in all, one, or a custom combination of the many <br /> available languages. You've probably stumbled across pages in a language <br /> you don't understand before, and you can save some time by excluding these <br /> from your search results. Figure 1-8 shows the current list of languages <br /> that Yahoo! lets you choose from, and you can select one or more from the <br /> list.<br /><br /><br /><br /><br /> Figure 1-8. The list of languages at Yahoo!<br /><br /><br /><br /><br /><br /> By default, Yahoo! displays results in any language. Of course, English <br /> search terms generally return web pages in English, but without setting <br /> this preference, you'll probably run into pages in other languages from <br /> time to time. For example, my last name is a common German last name, so a <br /> search for "Paul Bausch" yields both English and German pages.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 5. Assemble Advanced Search Queries<br /><br /><br /><br /><br /><br /> By understanding how Yahoo! Advanced Search URLs are structured, you can <br /> create your own Advanced Search queries on the fly.<br /><br /><br /> In addition to the simple search form you'll find at <br /> http://search.yahoo.com/, Yahoo! offers an Advanced Web Search form at <br /> http://search.yahoo.com/web/advanced. This form lets you refine your <br /> search in a number of ways, so you can narrow the results to a more useful <br /> list.<br /><br /><br /> For example, if you'd like to find information about a generic topic, such <br /> as astronomy, you could go to Yahoo!, type astronomy into the search form, <br /> and find hundreds of sites related to the word. But if you want only a <br /> segment of those results, you can browse over to the Advanced Web Search <br /> form, type astronomy, and limit the results by top-level domain, as shown <br /> in Figure 1-9.<br /><br /><br /><br /><br /> Figure 1-9. Yahoo! Advanced Search form<br /><br /><br /><br /><br /><br /> A search for astronomy across .gov sites returns only pages at NASA's web <br /> site. The same search limited to .edu sites results in astronomy programs <br /> at various universities, and limiting to .com gives you astronomy <br /> magazines at the top of the results.<br /><br /><br /> You can further refine your search by limiting it to a specific file <br /> format, such as PDF files, Excel spreadsheets, or XML files. For any given <br /> search, you can also override your global preferences settings for <br /> language, number of results, and adult content filtering.<br /><br /><br /> 1.6.1. Anatomy of an Advanced Search URL<br /><br /><br /> To get started with hacking URLs, type a term into the Advanced Web Search <br /> form and click the Yahoo! Search button, which will take you to the <br /> results page. Once there, note the insanely long URL in the address of <br /> your browser. It will look something like this:<br /><br /><br /> http://search.yahoo.com/search?_adv_prop=web&x=op&ei=UTF-8&va=astronomy&va_<br /><br /><br /><br /> vt=any& vp_vt=any& <br />vo_vt=any&ve_vt=any&vd=all&vst=.gov&vs=.gov&vf=all&vm=p&<br /><br /><br /><br /> fl=0&n=20<br /><br /><br /><br /><br /> For any given search URL, some of the variables you'll find in the URL are <br /> redundant or not necessary. The web form basically acts as a URL-building <br /> tool that has assembled this URL for you, and it isn't picky about which <br /> variables it includes. By understanding the pieces of the URL, you can <br /> construct your own queries using shorter URLs without the form.<br /><br /><br /> Note that the domain is followed by /search?, followed by a series of <br /> variable/ value pairs separated by ampersands. Not all of these variables <br /> will affect the search results, but there are some that are useful to play <br /> with. The variables are a bit cryptic (to keep the URLs as short as <br /> possible), so here's a list of the relevant variables and what they <br /> represent.<br /><br /><br /> The v* variables represent the way you'd like Yahoo! to handle the phrase. <br /> You can choose from the following variables:<br /><br /><br /> Table 1-2. <br /><br /><br /> va<br /><br /> Use this variable when you're looking for all of the words in a <br /> particular query. A query with the value astronomy magazine finds <br /> pages that contain both astronomy and magazine.<br /><br /><br /> vp<br /><br /> This variable holds the search query when you want to match a <br /> specific phrase, so a query with the value astronomy magazine finds <br /> pages that contain the exact phrase astronomy magazine.<br /><br /><br /> vo<br /><br /> This variable indicates a search for any of the words in a <br /> particular query. So a query with the value astronomy magazine <br /> returns documents that contain either astronomy or magazine.<br /><br /><br /> ve<br /><br /> This variable indicates words that should not appear in any of the <br /> pages, and it must be used with one of the other variables. For <br /> example, combining one of the above queries with ve=NASA allows you <br /> to search for astronomy magazine on pages that don't include the <br /> term NASA.<br /><br /><br /><br /><br /><br /> Another group of similarly patterned variables lets you limit searching to <br /> a specific part of a document, such as the title or URL. The format for <br /> these variables is v*_vt, where the asterisk is replaced by the type of <br /> primary search query. The possible values include any, title,or url. For <br /> example, if you'd like to search for pages that have the exact phrase <br /> astronomy magazine in the title, use the vp and vp_vt variables together, <br /> like so:<br /><br /><br /> search?vp=astronomy+magazine&vp_vt=title<br /><br /><br /><br /><br /> If you'd like to limit your results to pages that have been updated <br /> recently, you can use the vd variable. You can get all results, which is <br /> the default, or limit them to pages updated within the last three months, <br /> six months, or year. The respective values for these are all, m3, m6,or y. <br /> So finding all documents that contain the phrase astronomy magazine that <br /> have been updated within the last three months looks like this:<br /><br /><br /> search?vp=astronomy+magazine&vp_vt=any&vd=m3<br /><br /><br /><br /><br /> The vs variable is useful for limiting searches to a top-level domain, <br /> such as .com. In addition to top-level searches, you can narrow things to <br /> a specific web site. If you want to find every mention of astronomy <br /> magazine at the specific web site http://www.cnn.com/, you could use the <br /> variable like this:<br /><br /><br /> search?vp=astronomy+magazine&vp_vt=any&vs=cnn.com<br /><br /><br /><br /><br /> The vf variable limits searches to a specific file type. Yahoo! supports a <br /> set number of file types, and here are the current values you can use with <br /> this variable:<br /><br /><br /><br /><br /> all<br /><br /><br /> The default value; returns any type of document<br /><br /><br /><br /><br /> html<br /><br /><br /> HTML documents<br /><br /><br /><br /><br /> pdf<br /><br /><br /> Adobe PDF files<br /><br /><br /><br /><br /> xl<br /><br /><br /> Microsoft Excel spreadsheets (note that this value is an abbreviation for <br /> the full file extension, .xls)<br /><br /><br /><br /><br /> ppt<br /><br /><br /> Microsoft PowerPoint presentations<br /><br /><br /><br /><br /> msword<br /><br /><br /> Microsoft Word files<br /><br /><br /><br /><br /> rss<br /><br /><br /> Files formatted for syndication across web sites<br /><br /><br /><br /><br /> text<br /><br /><br /> Plain text files, which typically end with .txt<br /><br /><br /> To continue with the example, say you want to find the phrase astronomy <br /> magazine in only PowerPoint presentations. Append the vf variable, like <br />so:<br /><br /><br /> search?vp=astronomy+magazine&vp_vt=any&vf=ppt<br /><br /><br /><br /><br /> The number of results is controlled by the n variable, which can be set <br /> only to some predetermined values: 10, 15, 20, 30, 40,or 100. To return <br /> the first 40 results for the phrase astronomy magazine, add the n <br /> variable, like so:<br /><br /><br /> search?vp=astronomy+magazine&vp_vt=any&n=40<br /><br /><br /><br /><br /> There are other variables in advanced search URLs, but these are a few <br /> that will affect the content of search results. Now that you know why the <br /> initial Advanced Web Search URL was so long, you can use some of the <br /> variables to create your own advanced Yahoo! searches on the fly.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 6. Translate Any Page with Yahoo!<br /><br /><br /><br /><br /><br /> The World Wide Web has pages in every language, and Yahoo! can help you <br /> break through the language barrier.<br /><br /><br /> Because the Web is a global space, we've all come across pages in <br /> different languages, especially among search results. If you're searching <br /> for information about a phrase like hamburger recipe, it's strange to come <br /> across a page about it in German. It's stranger still to find a mention of <br /> your name on a page in a foreign language. Imagine my surprise when I was <br /> searching Yahoo! for my name and found it at the Russian site shown in <br /> Figure 1-10.<br /><br /><br /><br /><br /> Figure 1-10. Russian text with my name (Paul Bausch)<br /><br /><br /><br /><br /><br /> I can't read Russian, so of course I had no idea what the text said. I had <br /> recently added a photo gallery of old radio dials to my web site; I could <br /> tell they were linking to it, but I wanted to know what they were saying.<br /><br /><br /> 1.7.1. Yahoo! Language Tools<br /><br /><br /> Yahoo!'s Language Tools page (http://tools.search.yahoo.com/language) has <br /> some ways to help you work with other languages. Among them is a <br /> translation service that will translate any block of text to a different <br /> language. I copied the Russian text from Figure 1-10, pasted it into the <br /> text area labeled "Translate this web text," chose "From Russian to <br /> English" from the drop-down list of languages, and clicked Translate. <br /> Yahoo! responded with this:<br /> Radio Dials. The gallery of the photographs of ancient, I will not <br /> beafraid this word, radios-scale. The author of collection, <br /> photographerPaul Bausch, decided thus to publish the paternal collection <br /> of radioreceivers. 3x, dreams about their own tsifrozerkalke with <br /> themacro-objective become increasingly more importunately. <br /><br /><br /> As you can see, the Yahoo! translation tool isn't perfect, but it's good <br /> enough to give a sense of what the page is talking about. The translated <br /> text refers to the "paternal collection" of photos, because the radios I <br /> photographed belonged to my father. I still have no idea what the last <br /> sentence of the translation means, but I'm closer to understanding now <br /> than when it was in Russian.<br /><br /><br /><br /><br /> If you'd like to limit the search results that Yahoo! returns <br /> to one language or a handful of languages, you can set your <br /> preferred languages in your search preferences. By default, <br /> Yahoo! returns the best search results from any language.<br /><br /><br /><br /><br /><br /><br /> A faster way to translate any page you find in Yahoo! Search results is <br /> via the "Translate this page" link included within the results for <br /> non-English pages. Figure 1-11 highlights the link in the search results.<br /><br /><br /><br /><br /> Figure 1-11. The "Translate this page" link in Yahoo! Search results<br /><br /><br /><br /><br /><br /> Clicking the "Translate this page" link takes you to a translated version <br /> of the page, rather than the page in its original language.<br /><br /><br /> If you find yourself translating pages frequently, there are some ways to <br /> speed up the process. You can translate an entire web page by copying and <br /> pasting the URL into the field labeled "Translate this web page" on the <br /> Yahoo! Language Tools page, choosing the language from the drop-down menu, <br /> and clicking Translate. Yahoo! will display the page with all of the text <br /> translated.<br /><br /><br /> Another quick way to translate entire pages is with the Yahoo! Toolbar <br /> [Hack #12]. If you've already installed the Yahoo! Toolbar, choose <br /> Add/Edit Buttons… from the Toolbar Settings button to bring up the <br /> Customize Yahoo! Toolbar page. Check the box next to Translate Current <br /> Page under Search & Navigation and then click Finished. You should now see <br /> a small yellow fish button, like the one shown in Figure 1-12, on your <br /> toolbar.<br /><br /><br /><br /><br /> Figure 1-12. The Translate button on the Yahoo! Toolbar<br /><br /><br /><br /><br /><br /> From any web page, you can click the Translate button and Yahoo! will <br /> display a version in English. Yahoo! will also automatically detect the <br /> source language, so you don't need to choose a language from a menu. This <br /> is also handy if you can't tell what language the page is in. If you just <br /> want to translate a block of text instead of the entire page, you can <br /> click the arrow next to the fish and choose Language and Translation Tools <br /> from the menu; you'll go to the Yahoo! Language Tools page, where you can <br /> paste the text you want to translate into the translation form.<br /><br /><br /> If the Yahoo! Toolbar isn't your style and copying and pasting into the <br /> Language Tools isn't fast enough, you can create your own Translate button <br /> with an understanding of Yahoo! Translation URLs and a JavaScript <br /> bookmarklet.<br /><br /><br /> 1.7.2. A Translation Bookmarklet<br /><br /><br /> If you visit the Yahoo! Language Tools page and translate a page by URL, <br /> you'll end up at a Yahoo! page that uses frames. The top frame includes <br /> the Yahoo! Search logo and several links: View Original, Print <br /> Translation, Language Tools, and so on. The bottom frame is the original <br /> web page, with all of the text translated into a different language. <br /> Figure 1-13 shows such a translated page, with the O'Reilly Hacks page in <br /> Spanish in the bottom frame.<br /><br /><br /><br /><br /> Figure 1-13. The Hacks site translated into Spanish<br /><br /><br /><br /><br /><br /> Looking at the URL in the address bar, you'll see that you're at a Yahoo! <br /> page with some parameters passed to it in the querystring, including the <br /> URL of the page to be translated. The whole URL looks like this:<br /><br /><br /> http://tools.search.yahoo.com/language/ translation/translatedPage.<br /><br /><br /><br /> php?tt=url& urltext=http%3A%2F%2Fhacks.oreilly.com%2F& lp=en_es<br /><br /><br /><br /><br /> Here are the three variables passed in the URL:<br /><br /><br /><br /><br /> tt<br /><br /><br /> The type of translation to perform<br /><br /><br /><br /><br /> urltext<br /><br /><br /> The URL of the page to translate<br /><br /><br /><br /><br /> lp<br /><br /><br /> A code that represents the language to translate from and to<br /><br /><br /> Knowing how to build Yahoo! Translate URLs, you can create a bookmarklet <br /> to fetch the current page URL, construct the proper Yahoo! Translate URL, <br /> and open it in a new window.<br /><br /><br /> 1.7.2.1. The code.<br /><br /><br /> As with other Yahoo! bookmarklets throughout this book, this JavaScript is <br /> not very readable, but is condensed to work within the confines of a <br /> browser bookmark. Create a new bookmark in your browser and then bring it <br /> up for editing. Put the following code into the location field of the <br /> bookmark and be sure to give the bookmarklet a descriptive name, such as <br /> Yahoo! Translate:<br /><br /><br /> javascript:d=document;void(window.open('http://tools.search.yahoo.com/<br /><br /><br /><br /> language/ <br /> translation/translatedPage.php?tt=url&urltext='+escape(d.location.<br /><br /><br /><br /> href)+'& <br />lp=xx_en','_blank','width=640,height=480,status=yes,resizable=yes,<br /><br /><br /><br /> scrollbars=yes'))<br /><br /><br /><br /><br /> The value of the lp variable in this code is important to note. The value <br /> xx_en tells Yahoo! to determine the language of the page you've sent it to <br /> translate. Of course, you could make this a language-specific bookmarklet <br /> by replacing xx_en with es_en (Spanish to English), fr_de (French to <br /> German), or any one of the other codes for the translations that Yahoo! <br /> supports. To view a full list of translation codes, simply view the source <br /> of the Language Tools page and look at the value attribute in the <option> <br /> tags that display the language choices. There are a few option lists on <br /> the page, so look for the list that contains values in the xx_yy format.<br /><br /><br /> 1.7.2.2. Running the hack.<br /><br /><br /> To run the code, browse to a foreign-language page and click Yahoo! <br /> Translate from your bookmarks. A new browser window will open, showing a <br /> translated version of the original page. Figure 1-14 shows a Japanese page <br /> in the background that has been translated into English in the foreground.<br /><br /><br /><br /><br /> Figure 1-14. A page that has been translated from Japanese to English<br /><br /><br /><br /><br /><br /> The automatic translation might provide less-than-fluid English, but if <br /> you ever find your name on a page in a language you don't speak, you can <br /> find out why with a single click.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 7. Personalize, Track, and Share the Web<br /><br /><br /><br /><br /><br /> A free Yahoo! service called My Web remembers your searches, saves copies <br /> of web pages, and shares your saved pages with others.<br /><br /><br /> The Yahoo! My Web beta gives you a powerful set of tools to collect web <br /> pages, annotate them, and share them with others. In My Web, you can save <br /> links to your favorite web sites (much like bookmarks) and organize them <br /> in custom folders. But there are several features available at My Web <br /> beyond collecting links:<br /><br /><br /><br /><br /> Site Notes<br /><br /><br /> You can add notes to any saved web site in My Web. You can use these notes <br /> to provide a site description, personal comments about the site, or any <br /> other bits of text.<br /><br /><br /><br /><br /> Copies of Web Pages<br /><br /><br /> Instead of saving just a link to a web site, My Web saves a copy of a page <br /> as it looked when you added it My Web. So even if a web page changes <br /> between when you added the site to My Web and when you want to reference <br /> it later, you can be sure you'll see the original information.<br /><br /><br /><br /><br /> Search History<br /><br /><br /> If you enable Search History, Yahoo! will remember which sites you click <br /> on in any Yahoo! search results and save them to your My Web History <br /> folder. If you have trouble remembering what search term you used to find <br /> a particular site, this might be a useful feature for you.<br /><br /><br /><br /><br /> Blocked Sites<br /><br /><br /> Some sites that show up in search results simply aren't relevant and won't <br /> be relevant to any search you make. Clicking Block tells Yahoo! not to <br /> show that particular site in your future search results. Blocked sites <br /> show up in your My Web Blocked folder, so you can periodically review the <br /> sites you've blocked.<br /><br /><br /><br /><br /> Shared Folders<br /><br /><br /> By default, folders with links and copied pages are private, but you can <br /> also choose to share any particular folder with the world. My Web also <br /> makes RSS feeds available for shared folders so others can subscribe to <br /> them and keep up with your changes.<br /><br /><br /> To get started with My Web you just need a free Yahoo! ID. Browse to <br /> http://myweb.search.yahoo.com/myweb and log in with your Yahoo! ID. As you <br /> activate My Web, you'll have the option to import any existing Yahoo! <br /> Bookmarks (http://bookmarks.yahoo.com/) and the option to download the <br /> latest Yahoo! Toolbar (http://toolbar.yahoo.com/), which is a quick way to <br /> add links to My Web as you browse other sites.<br /><br /><br /> 1.8.1. Using My Web<br /><br /><br /> Once you've enabled My Web, you'll see some extra options as you search <br /> with Yahoo!. Make sure you're logged into Yahoo! and then browse to <br /> http://search.yahoo.com/. The first change you'll notice is a My Web link <br /> under the Yahoo! logo, and the status of your Search History feature, as <br /> shown in Figure 1-15.<br /><br /><br /><br /><br /> Figure 1-15. My Web link and Search History status at Yahoo! Search<br /><br /><br /><br /><br /><br /> Click Off or On at any time to enable or disable the Search History <br /> feature, respectively.<br /><br /><br /> Each search result on the page will also have two links Save and Blockas <br /> shown in Figure 1-16.<br /><br /><br /><br /><br /> Figure 1-16. The Save and Block links on a search result<br /><br /><br /><br /><br /><br /> Clicking Save brings up a form on the page that will allow you to choose a <br /> folder to save the site in, and a text field for adding notes to the site. <br /> Figure 1-17 shows the Save form.<br /><br /><br /><br /><br /> Figure 1-17. The Save form on a search result<br /><br /><br /><br /><br /><br /> Clicking Block produces the message shown in Figure 1-18, notifying you <br /> that the site will be blocked from future searches.<br /><br /><br /><br /><br /> Figure 1-18. Notification that a site has been blocked<br /><br /><br /><br /><br /><br /> You can click Unblock Site to restore the site in the current search <br /> results, or you can visit your Blocked folder to put the site back into <br /> view on future searches.<br /><br /><br /> If you want to take the features of My Web with you to other web sites, <br /> you can use the Yahoo! Toolbar [Hack #12]. If you don't see the My Web <br /> button represented by a yellow folder on your toolbar, be sure you have <br /> the latest version of the toolbar (available at <br /> http://toolbar.yahoo.com/). You can also choose Add/Edit Buttons from the <br /> toolbar settings button, check the box next to My Web under Personal <br /> Tools, and click the Finished button. Once the My Web button is installed, <br /> you should see it with its related pull-down menu, as shown in Figure <br />1-19.<br /><br /><br /><br /><br /> Figure 1-19. Yahoo! Toolbar My Web menu<br /><br /><br /><br /><br /><br /> If you want to save a particular web page, click on the yellow folder icon <br /> with the green plus (+) sign. The pop-up windowlike the one shown in <br /> Figure 1-20lets you modify the saved title, add a note about the page, <br /> save it to a specific My Web folder, and store the actual contents of the <br /> page just as if you'd clicked the Save button next to a Yahoo! Search <br /> result.<br /><br /><br /> 1.8.2. Sharing My Web<br /><br /><br /> As you browse through your saved sites at <br /> http://myweb.search.yahoo.com/myweb, you have the option to make folders <br /> full of sites public (they're private by default). Simply click the radio <br /> button next to Public in the My Web folder publishing options (see Figure <br /> 1-21).<br /><br /><br /> Once your My Web folder is public, anyone will be able to view the sites <br /> you've saved to that folder in a number of ways. You can share the <br /> collection of web pages in a My Web folder directly via a predictable URL. <br /> Public folder URLs follow this pattern:<br /><br /><br /> http://myweb.search.yahoo.com/myweb/user/hashed account/folder name<br /><br /><br /><br /><br /><br /><br /> Figure 1-20. Yahoo! My Web "Save this page" pop-up window<br /><br /><br /><br /><br /><br /><br /><br /> Figure 1-21. Yahoo! My Web folder publishing options<br /><br /><br /><br /><br /><br /> The hashed account in the URL is a text string that is an encrypted <br /> version of your account name. To find your particular hashed account text, <br /> click the Preview link in your folder publishing options and take a look <br /> at the URL. You should see a seemingly random string of characters in the <br /> URL, something like this:<br /><br /><br /> YZWDcbcIupRv2bLnSax_Qg<br /><br /><br /><br /><br /> This is your hashed account name, and you can use it to build URLs to <br /> shared folders. The folder name in the URL pattern is, predictably, the <br /> name of the public folder. So if your folder is named ToddTechFinds, the <br /> final URL would look like this:<br /><br /><br /> http://myweb.search.yahoo.com/myweb/user/YZWDcbcIupRv2bLnSax_Qg/<br /><br /><br /><br /> ToddTechFinds<br /><br /><br /><br /><br /> You could then pass this URL along to friends or coworkers so that they <br /> can see the sites you've gathered together. If you frequently update the <br /> folder, there are a couple of options that let others subscribe to any <br /> public My Web folder.<br /><br /><br /> People viewing your site with a My Yahoo! account can choose to add your <br /> page to their My Yahoo! RSS feed list. This lets them get updates about <br /> content in your shared folder. And Yahoo! also provides a direct link to <br /> the syndicated RSS 2.0 format XML. The RSS feeds also have a predictable <br /> URL that follows this pattern:<br /><br /><br /> http://myweb.search.yahoo.com/myweb/user/hashedaccount/foldername/rss.xml<br /><br /><br /><br /><br /> Of course, this RSS 2.0 feed URL can be found by clicking on the familiar <br /> XML button.<br /><br /><br /> 1.8.3. Programming My Web<br /><br /><br /> In addition to the web and RSS options available for sharing My Web sites, <br /> you can access your public folders via Yahoo! Web Services. The <br /> documentation for the My Web API is found at <br /> http://developer.yahoo.net/myweb.<br /><br /><br /> There are two public My Web functions. The listFolders function lists the <br /> public folders for a Yahoo! My Web account. You can call it like so:<br /><br /><br /> http://api.search.yahoo.com/MyWebService/V1/listFolders?appid=insert <br /><br /><br /><br /> appID&yahooid=insert Yahoo! ID&results=10 <br /><br /><br /><br /><br /> Replace insert appID with your own Yahoo Application ID and use someone <br /> else's Yahoo! ID for insert Yahoo! ID. The URL returns an XML page that <br /> contains a list of that user's public folders, along with the number of <br /> sites in that folder. You can parse the XML with any programming <br /> environment.<br /><br /><br /> The listUrls function returns information about a specific public folder. <br /> You can call it with a URL like this:<br /><br /><br /> http://api.search.yahoo.com/MyWebService/V1/listUrls?appid=insert<br /><br /><br /><br /> appID&yahooid=insert Yahoo! ID&folder=insert public folder&results=10<br /><br /><br /><br /><br /> This function is handy for browsing the contents of folders you found with <br /> the listFolders function.<br /><br /><br /> A basic example of using My Web data programmatically is to display the <br /> sites in a public folder on a remote web sitea perfect job for PHP.<br /><br /><br /> 1.8.3.1. The code.<br /><br /><br /> The PHP 5 integrated SimpleXML module makes parsing and displaying the XML <br /> easy. The simplexml_load_file( ) function retrieves the My Web web <br /> servicesgenerated XML for easy parsing. The foreach loop iterates through <br /> the list of saved web pages and lets you extract individual items. Note <br /> that the tag names are case-sensitive. For example, $result->Url succeeds, <br /> but $result->URL fails.<br /><br /><br /> The following simple PHP 5 script, showMyWebFolder.php, displays the <br /> contents of a public My Web folder:<br /><br /><br /> <?php<br /> $myweb = simplexml_load_file('http://api.search.yahoo.com/MyWebService/V1/<br /><br /><br /><br /> listUrls?appid=insert appID&yahooid=insert Yahoo! ID&folder=insert public<br /><br /><br /><br /> folder&results=10');<br /><br /><br /> print "<h2>Shared Links</h2>"; <br /> foreach ($myweb->Result as $result) <br /> {<br /> $date_text = $result->StoreDate;<br /> $summary_text = $result->Summary;<br /> $title_text = $result->Title;<br /> $url_text = $result->Url;<br /> $note_text = $result->Note;<br /><br /><br /> print "<h3>" . date("M d, Y", $date_text) . "</h3>\n";<br /> print "<a href=\"$url_text\">";<br /> print $title_text;<br /> print "</a>" . "<br />";<br /> print "<div>$summary_text</div><br />";<br /> print "<div style=\"background:#eee;\"><b>Notes:</b><br /> $note_text</div>";<br /> }<br /><br /><br /><br /><br /> Be sure to create and include a unique application ID and insert your own <br /> Yahoo! ID and public folder name.<br /><br /><br /> 1.8.3.2. Running the hack.<br /><br /><br /> Upload showMyWebFolder.php to your server and bring it up in a browser. <br /> You should see a simple HTML page, like the one shown in Figure 1-22. This <br /> page shows the links, notes, and date each site was added to the public <br /> folder.<br /><br /><br /><br /><br /> Figure 1-22. The contents of a My Web folder on a remote site<br /><br /><br /><br /><br /><br /> At the time of this writing, My Web is still in beta testing, but with its <br /> powerful abilities to annotate, share, and shape search results, My Web <br /> will likely be a standard part of Yahoo! in the future.<br /><br /><br /> Todd Ogasawara and Paul Bausch<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 8. Prefetch Yahoo! Search Results<br /><br /><br /><br /><br /><br /> Automatically prefetch and cache the first search result on Yahoo! Web <br /> Search.<br /><br /><br /> If you know how to use them properly, search engines are pretty darn good <br /> at finding exactly the page you're looking for. Google is so confident in <br /> its algorithm that it includes a hidden attribute in the search results <br /> page that tells Firefox to prefetch the first search result and cache it. <br /> You're probably going to click on the first result anyway, and when you <br /> do, it will load almost instantaneously because your browser has already <br /> been there.<br /><br /><br /> Yahoo! Web Search is pretty good too, but it doesn't yet have this <br /> particular feature. So let's add it.<br /><br /><br /><br /><br /> This hack relies on the Greasemonkey extension and thus works <br /> only in Firefox. If you're interested in doing much more with <br /> Greasemonkey, see Mark Pilgrim's forthcoming Greasemonkey <br /> Hacks, from which this hack is excerpted.<br /><br /><br /><br /><br /><br /><br /> To begin, you'll need to install the Greasemonkey plug-in for Firefox. If <br /> you don't already have it, browse to http://greasemonkey.mozdev.org/ and <br /> click the Install Greasemonkey link. Follow the Software Installation <br /> prompts and then restart your browser. You'll know the plug-in is working <br /> if you see a small monkey icon in the lower-right corner of Firefox. Once <br /> installed, you can move on to analyzing Yahoo! and building the <br /> Greasemonkey script.<br /><br /><br /> There are two important things about Yahoo! Search results that you can <br /> discover by viewing source on the search results page. First, the links of <br /> the search results each have a class yschttl. Yahoo uses this for styling <br /> the links with CSS, but you can use it to find the links in the first <br /> place. A single XPath query can extract a list of all the links with the <br /> class yschttl, and the first one of those is the one we want to prefetch <br /> and cache.<br /><br /><br /> The second thing you need to know is that the search results Yahoo! <br /> provides are actually redirects through a tracking script on rds.yahoo.com <br /> that records which link you clicked on. A sample link looks like this:<br /><br /><br /> http://rds.yahoo.com/S=2766679/K=gpl+compatible/v=2/SID=e/TID=F510_112/<br /><br /><br /><br /> l=WS1/R=2/IPC=us/SHE=0/H=1/SIG=11sgv1lum/EXP=1116517280/*-http%3A//<br /><br /><br /><br /> www.gnu.org/licenses/gpl-faq.html<br /><br /><br /><br /><br /> To save time and bandwidth, and to avoid skewing Yahoo's tracking <br /> statistics, this user script will extract the target URL out of the first <br /> search result link before requesting it. The target URL is always at the <br /> end of the tracking URL, after the *-, with characters such as colons (:) <br /> escaped into their hexadecimal equivalents. Here's the target URL in the <br /> previous example:<br /><br /><br /> http://www.gnu.org/licenses/gpl-faq.html<br /><br /><br /><br /><br /> When I say " prefetch and cache," there is really only one step: prefetch. <br /> By default, Firefox automatically caches pages according to HTTP's caching <br /> directives and your browser preferences. For this script to have the <br /> desired effect, make sure your browser preferences are set to enable <br /> caching pages. Open a new window or tab, go to about:config, and <br /> double-check the following preferences:<br /><br /><br /> * browser.cache.disk.enable /* should be "true" */<br /> * browser.cache.check_doc_frequency /* should be 0, 2, or 3 */<br /><br /><br /><br /><br /><br /><br /> about:config shows you all your browser preferences, even ones <br /> that are not normally configurable through the Options dialog. <br /> Type part of a preference name (such as browser.cache) in the <br /> Filter box to narrow the list of displayed preferences.<br /><br /><br /><br /><br /><br /><br /> 1.9.1. The Code<br /><br /><br /> Save the following user script as yahooprefetch.user.js:<br /><br /><br /> // ==UserScript==<br /> // @name Yahoo! Prefetcher<br /> // @namespace http://www.oreilly.com/catalog/ greasemonkeyhks/<br /> // @description prefetch first link on Yahoo! web search results<br /> // @include http://search.yahoo.com/search*<br /> // ==/UserScript==<br /><br /><br /> var elmFirstResult = document.evaluate("//a[@class='yschttl']", document,<br /> null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; <br /> if (!elmFirstResult) return; <br /> var urlFirstResult = unescape(elmFirstResult.href.replace(/^.*\*-/, '')); <br /> var oRequest = {<br /> method: 'GET',<br /> url: urlFirstResult,<br /> headers: {'X-Moz': 'prefetch',<br /> 'Referer': location.href}};<br /> GM_log(' prefetching ' + urlFirstResult);<br /> GM_xmlhttpRequest(oRequest);<br /><br /><br /><br /><br /> 1.9.2. Running the Hack<br /><br /><br /> To verify that the script is working properly, you'll need to clear your <br /> browser cache. You don't need to do this every time, just once to prove to <br /> yourself that the script is doing something. To clear your cache, go to <br /> the Tools menu and select Options; then go to the Privacy tab and click <br /> the Clear button next to Cache.<br /><br /><br /> Now, install the user script from Tools Install User Script, and then go <br /> to http://search.yahoo.com/ and search for gpl compatible. The prefetching <br /> happens in the background after the page is fully loaded, so wait for a <br /> second or two after the search results come up. There won't be any visible <br /> indication on screen that Firefox is prefetching the link. You might see <br /> some additional activity on your modem or network card, but it's hard to <br /> separate this from the activity of loading the rest of the Yahoo! Search <br /> results page.<br /><br /><br /> Open a new browser window or tab and go to about:cache. This displays <br /> information about Firefox's browser cache. Under "Disk cache device," <br /> click List Cache Entries. You should see a key for <br /> http://www.gnu.org/philosophy/license-list.html. This is the result of <br /> Firefox prefetching and caching the first Yahoo! Search result. Click that <br /> URL to see specific information about the cache entry, as shown in Figure <br /> 1-23.<br /><br /><br /><br /><br /> Figure 1-23. Information about a prefetched page<br /><br /><br /><br /><br /><br /> 1.9.3. Hacking the Hack<br /><br /><br /> By now you should realize that this prefetching technique can be used <br /> anywhere, with any links. Do you use some other search engine, perhaps a <br /> site-specific search engine such as Microsoft Developer's Network (MSDN)? <br /> You can apply the same technique to those search results.<br /><br /><br /> For example, going to http://msdn.microsoft.com/ and searching for active <br /> accessibility takes you to a search results page at this URL:<br /><br /><br /> http://search.microsoft.com/search/results.aspx?qu=active+accessibility&<br /><br /><br /><br /> View=msdn&st=b&c=0&s=1&swc=0<br /><br /><br /><br /><br /> If you view source on this page, you will see that the result links are <br /> contained within a <div class=" results"> tag. This means that the first <br /> result can be found with this XPath query:<br /><br /><br /> var elmFirstResult = document.evaluate("//div[@class=' results']//<br /><br /><br /><br /> a[@href]", <br /> document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).<br /><br /><br /><br /> singleNodeValue;<br /><br /><br /><br /><br /> Unlike with Yahoo! Search results, these search result links are not <br /> redirected through a tracking script, so you will need to change this <br />line:<br /><br /><br /> var urlFirstResult = unescape(elmFirstResult.href.replace(/^.*\*-/, ''));<br /><br /><br /><br /><br /> to this:<br /><br /><br /> var urlFirstResult = elmFirstResult.href;<br /><br /><br /><br /><br /> The rest of the script will work unchanged.<br /><br /><br /> Mark Pilgrim<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 9. Compare Yahoo! and Google Search Results<br /><br /><br /><br /><br /><br /> Pit Yahoo! and Google against each other and find more search results in <br /> the process.<br /><br /><br /> If you've ever searched for the same phrase at both Yahoo! and Google, <br /> you've probably noticed that the results can be surprisingly different. <br /> That's because Yahoo! and Google have different ways of determining which <br /> sites are relevant for a particular phrase. Though both companies keep the <br /> exact way that they determine the rank of results a secretto thwart people <br /> who would take advantage of itboth Yahoo! and Google provide some clues <br /> about what goes into their respective ranking systems.<br /><br /><br /> Here's the official word from Yahoo!:<br /><br /><br /> Yahoo! Search ranks results according to their relevance to a particular <br /> query by analyzing the web page text, title, and description accuracy as <br /> well as its source, associated links, and other unique document <br /> characteristics.<br /><br /><br /> At the heart of Google's ranking system is a proprietary method called <br /> PageRank, and Google doesn't give detailed information about it. But <br /> Google does say this:<br /><br /><br /> Google's order of results is automatically determined by more than 100 <br /> factors, including our PageRank algorithm.<br /><br /><br /> Though we might never know exactly why results are different between the <br /> two search engines, at least we can have some fun spotting the differences <br /> and end up with more search results than either one of the sites would <br /> have offered on its own.<br /><br /><br /> One way to compare results is to simply open each site in a separate <br /> browser window and manually scan for differences. If you search for your <br /> favorite dog breedsay, australian shepherdyou'll find that the top few <br /> sites are the same across both Yahoo! and Google, but the two search <br /> engines quickly diverge into different results. At the time of this <br /> writing, both sites estimate exactly 1,030,000 total results for this <br /> particular query, but estimated result counts are sometimes a way to spot <br /> differences between the sites.<br /><br /><br /> Viewing both sets of results in different windows is a bit tedious, and a <br /> clever Norwegian developer named Asgeir S. Nilsen has made the task easier <br /> at a site called Twingine.<br /><br /><br /> 1.10.1. Twingine<br /><br /><br /> The Twingine site (http://twingine.com/) contains a blank search form into <br /> which you can type any search query. When you click Search, the site <br /> brings up the results pages for that query from both Yahoo! and Google, <br /> side by side. For fairness, Twingine randomly changes the sides that <br /> Google and Yahoo! come up on, so people who prefer one side of the screen <br /> over the other won't be biased. Plugging australian shepherd into Twingine <br /> yields a page like the one shown in Figure 1-24.<br /><br /><br /><br /><br /> Figure 1-24. Google and Yahoo! going head to head at Twingine<br /><br /><br /><br /><br /><br /> Clicking Next or Previous in the top frame at Twingine takes you to the <br /> next or previous page in the search results at both sites.<br /><br /><br /> Surfing the pages in the search results at Twingine at can be a bit <br /> tricky. You'll probably want to open linked search results in a new window <br /> or tab, so that you can keep your place in the search results at both <br /> Yahoo! and Google. You can open links in a new window by right-clicking <br /> the link (Ctrlclick on a Mac) and choosing "Open Link in New Window" from <br /> the menu. You can also set your Yahoo! Search preference to automatically <br /> open links in a new window when you're clicking a Yahoo! Search result.<br /><br /><br /> 1.10.2. Yahoo! Versus Google Diagram<br /><br /><br /> Another site, developed by Christian Langreiter, adds a bit of analysis to <br /> the differing sets of search results between Yahoo! and Google. If you <br /> have Flash installed, you can type a search query into the form at <br /> http://www.langreiter.com/exec/yahoo-vs-google.html and the site fetches <br /> the search results from both engines in the background using their open <br /> APIs. The site delivers the results in a chart like the one shown in <br /> Figure 1-25.<br /><br /><br /><br /><br /> Figure 1-25. Mapping the differences between Yahoo! and Google results<br /><br /><br /><br /><br /><br /> Each blue or white dot in the diagram represents a search result URL, and <br /> the position of the dot represents the ranking. The dots on the far left <br /> are the top search results, and the further right you go, the further down <br /> you go in the search results. The blue lines represent the same URL, so <br /> you can see exactly where Google and Yahoo! line up. In Figure 1-25, you <br /> can see that the top search result for australian shepherd is the same <br /> URL, but the lines aren't as evenly matched further down in the results. <br /> As you hover over each dot, you'll see the URL, which you can click to <br /> visit that particular search result.<br /><br /><br /> The white dots in the diagram represent a URL that one search has in the <br /> results that the other does not. And as this diagram demonstrates, neither <br /> search engine has a monopoly on matching pages, nor does each engine's <br /> index have every page on a particular topic.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 10. Find Content You Can Reuse Legally<br /><br /><br /><br /><br /><br /> Use the Yahoo! Creative Commons Search to find text and images with <br /> special licenses.<br /><br /><br /> Most of the text, images, and audio you find through a Yahoo! Search are <br /> copyrighted materials. In fact, even if the author of a page or image <br /> doesn't specify that her work is copyrighted, a copyright still exists; by <br /> default, all works are copyrighted. This means you can never be sure how a <br /> particular author will react if you use part or all of her work in your <br /> own project.<br /><br /><br /> Say you're preparing a public presentation and you'd like to use a photo <br /> of the Statue of Liberty. Unless you specifically pay for an image, you <br /> can't be sure the photographer of a photo you find on the Web won't sue <br /> you for copyright violation. Without contacting the photographer (or owner <br /> of the copyright), there's no way to know what he'll consider a fair use <br /> of his materials. While there is a legal concept called fair use that <br /> protects some use of copyrighted materialsespecially for educational <br /> useit's hard to know exactly which uses fall under this legal definition, <br /> because the concept of fair use is only vaguely defined.<br /><br /><br /> This legal ambiguity is one of the reasons the nonprofit group Creative <br /> Commons ( CC) has made several alternative licenses available to artists <br /> who want to license their work in a more specific way than a general <br /> copyright provides. For example, an artist can make her work available to <br /> anyone who wants to use his photo or text on the condition that it's used <br /> for noncommercial purposes, but the artist can still require payment for <br /> any commercial use. This means you could use a photo licensed in this way <br /> for a school report, but you'd need to pay the photographer if you were <br /> compiling a book you intended to sell. With a CC license, you know exactly <br /> how the artist would like her work to be usedor not used.<br /><br /><br /> Another compelling aspect is that as long as you're following the <br /> conditions set forth in the license, you don't need to pay the artist to <br /> use the workor even contact her asking to use the work. If for any reason <br /> you'd like to use the work in a way that's not covered by the license, <br /> however, you'll need to contact the artist. Basically, you just need to <br /> know how the Creative Commons licenses work to make sure you're playing by <br /> the rules.<br /><br /><br /> 1.11.1. Understanding CC Licenses<br /><br /><br /> There are four primary conditions that Creative Commons offers in its <br /> licenses, in different combinations:<br /><br /><br /><br /><br /> Attribution<br /><br /><br /> No matter how you use the work, you must give the author credit. All <br /> licenses include this condition.<br /><br /><br /><br /><br /> NoDerivs (No Derivatives)<br /><br /><br /> You can use only exact copies of the work in its entirety, not pieces of <br /> the work arranged in a different way.<br /><br /><br /><br /><br /> NonCommercial<br /><br /><br /> The work can only be used for a noncommercial project.<br /><br /><br /><br /><br /> ShareAlike<br /><br /><br /> You can use the work as long as your work is licensed in the same way.<br /><br /><br /> And here are the six licenses offered with these uses in combination:<br /><br /><br /><br /> Attribution <br /><br /><br /><br /> Attribution-NoDerivs <br /><br /><br /><br /> Attribution-NonCommerical-NoDerivs <br /><br /><br /><br /> Attribution-NonCommercial <br /><br /><br /><br /> Attribution-NonCommercial-ShareAlike <br /><br /><br /><br /> Attribution-ShareAlike <br /><br /><br /> So if you spot a photograph of the Statue of Liberty on the Web with an <br /> Attribution-NoDerivs CC license, you know that the author has made his <br /> photo available to anyone who wants to use it for any purpose. In <br /> exchange, the author wants credit for the photo and wants you to use the <br /> photo in its entirety, rather than cropping the photo or blending it with <br /> other photos. The other licenses work in a similar way. Once you know the <br /> four conditions, you can quickly determine how the author would like you <br /> to use the work by looking at combinations in the license.<br /><br /><br /> 1.11.2. Finding CC-Licensed Content<br /><br /><br /> Yahoo! has created a special search form (in beta testing at the time of <br /> this writing) for finding content with CC licenses. The Yahoo! Creative <br /> Commons Search is available at http://search.yahoo.com/cc and provides a <br /> few options for filtering results, as shown in Figure 1-26.<br /><br /><br /><br /><br /> Figure 1-26. Yahoo! Creative Commons Search form<br /><br /><br /><br /><br /><br /> You can leave both checkboxes under the search form blank to find all <br /> types of CC licenses. Alternately, you can find content that doesn't have <br /> the NonCommercial condition, content that doesn't have the NoDerivs <br /> condition, or both, by checking the boxes accordingly.<br /><br /><br /> The search results look exactly like standard Yahoo! Search results but <br /> take you to pages with CC-licensed material. Once you visit the site, <br /> you'll need to find out which license the author has chosen for her work. <br /> Look around the page for a Creative Commons logo like the one shown in <br /> Figure 1-27.<br /><br /><br /><br /><br /> Figure 1-27. Creative Commons logo and license link<br /><br /><br /><br /><br /><br /> Click the logo or link, and you'll see exactly which license the work is <br /> under. Figure 1-28 shows the license page at Creative Commons that <br /> explains an Attribution-NonCommerical-ShareAlike license.<br /><br /><br /><br /><br /> Figure 1-28. A Creative Commons license page<br /><br /><br /><br /><br /><br /> Note that the URL for the license page includes an indication of which <br /> license type you're looking at. In this example, the URL is:<br /><br /><br /> http://creativecommons.org/licenses/by-nc-sa/2.0/<br /><br /><br /><br /><br /> The combination of two-letter codes after licenses/ shows the type of <br /> license that you'll find at that URL. Here's the shorthand for the <br /> conditions:<br /><br /><br /> Table 1-3. <br /><br /><br /> by<br /><br /> Attribution<br /><br /><br /> nd<br /><br /> NoDerivs<br /><br /><br /> nc<br /><br /> NonCommericial<br /><br /><br /> sa<br /><br /> ShareAlike<br /><br /><br /><br /><br /><br /> Just by looking at the URL, you can tell that by-nc-sa represents an <br /> Attribution-NonCommerical-ShareAlike license. As you work with Creative <br /> Commonslicensed material, you can spot the license quickly this way, by <br /> hovering your mouse over a CC logo and noting the URL in the status bar of <br /> your browserwithout having to visit the license page.<br /><br /><br /> So the next time you're looking for supporting text or photographs, you <br /> can use the Yahoo! Creative Commons Search to find something appropriate, <br /> such as Sheila Morris's photograph of the Statue of Liberty in Figure <br />1-29.<br /><br /><br /><br /><br /> Figure 1-29. CC-licensed image of the Statue of Liberty<br /><br /><br /><br /><br /><br /> Sheila Morris published the photo under an Attribution license, which <br /> means she simply wants credit in exchange for use of the photo. Paying <br /> attention to CC-licensed material takes the ambiguity out of the standard <br /> copyright system and lets you know how you can use some materials you find <br /> on the Web.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 11. Find Video from Across the Web<br /><br /><br /><br /><br /><br /> The Yahoo! Video Search can help you find video clips that have been <br /> posted to the Web.<br /><br /><br /> As Yahoo! Search scours the Web, it indexes not only the documents, text, <br /> and images it finds, but also video clips. Video files don't show up in a <br /> standard Yahoo! Web Search, but you can visit the Yahoo! Video Search to <br /> find clips from every corner of the Web.<br /><br /><br /> 1.12.1. Simple Video Searching<br /><br /><br /> To start finding videos, browse to http://video.yahoo.com/ (or type video <br /> search! into any Yahoo! Search form), enter a word or phrase, and click <br /> Search Video. Say you're interested in learning more about NASA's robotic <br /> vehicle for exploring Mars and you'd like to see the rover in action. You <br /> can find thumbnails of videos from across the Web by searching with the <br /> phrase mars rover, as shown in Figure 1-30.<br /><br /><br /><br /><br /> Figure 1-30. Results of a Video Search for "mars rover"<br /><br /><br /><br /><br /><br /> Among the hundreds of results are clips from professional television news <br /> stories about the Mars rover, clips from NASA itself with video from the <br /> Mars rover, and amateur videos about the Mars rover. Yahoo! displays a <br /> single frame from the video, the name of the file, the video's dimensions, <br /> and the URL that contains a link to the video clip. To view a video, just <br /> click the thumbnail. The video will open from its original site within a <br /> Yahoo! frame, like the clip shown in Figure 1-31.<br /><br /><br /> The top frame of a search result detail contains the video thumbnail, a <br /> link to play the video within your browser, and a link to send an email <br /> with a link to the clip. The bottom frame shows the page where the video <br /> was found, so you can see the video in its original context.<br /><br /><br /><br /><br /> The videos you find through Yahoo! Video Search might be <br /> protected by copyright laws, so you'll need to be mindful of <br /> how you use any materials you find.<br /><br /><br /><br /><br /><br /><br /><br /><br /> Figure 1-31. A Video Search result detail showing the video in context<br /><br /><br /><br /><br /><br /> 1.12.2. Advanced Video Searching<br /><br /><br /> As with a Yahoo! Web Search, there's an advanced video search form <br /> (http://video.search.yahoo.com/video/advanced). You can use the advanced <br /> search form to limit results to specific video formats, one of three sizes <br /> of videos small, medium, or largeand videos that are longer or shorter <br /> than one minute. As with the Web Search, you can also limit your search to <br /> a specific site or adjust the SafeSearch features for the search.<br /><br /><br /> As an example of a specific search, you could still use the phrase mars <br /> rover, but limit the search to MPEG and Quicktime files that are shorter <br /> than a minute long, small in size, and found on a government domain. <br /> Instead of hundreds of results to sort through in a broad mars rover <br /> search, you'll find five clips from a NASA site with the narrowly defined <br /> advanced search.<br /><br /><br /> If the advanced search controls still don't provide enough control over <br /> your query, there are several special search keywords you can use to <br /> refine your video searches further.<br /><br /><br /><br /><br /> At the time of this writing, these video keywords aren't <br /> documented on Yahoo!, so thanks go to Stig Sæther Bakken and <br /> David Hall from Yahoo! for sharing the syntax elements listed <br /> here.<br /><br /><br /><br /><br /><br /><br /> Here's a look at each of the special syntax keywords and how they'll <br /> refine a search. Note that a keyword is followed by a colon and a value <br /> with no space in between.<br /><br /><br /><br /><br /> filesize<br /><br /><br /> Limits search results to files of a specific size, in bytes. You can use <br /> this in combination with a greater-than sign (>) or less-than sign (<)to <br /> find files that are larger or smaller than the specified amount, <br /> respectively. For example, filesize:<1073741824 limits results to video <br /> files that are smaller than one gigabyte.<br /><br /><br /><br /><br /> date<br /><br /><br /> Limits results to videos that have been last modified on, before, or after <br /> a certain date. You need to use a Unix-style date, which is the time in <br /> seconds since January 1, 1970. So a query that includes date:>1107803581 <br /> returns results with videos that have been modified after February 7, <br />2005.<br /><br /><br /><br /><br /> width<br /><br /><br /> Finds videos of a specific width in pixels. A query with width:640 finds <br /> videos that are 640 pixels wide.<br /><br /><br /><br /><br /> height<br /><br /><br /> Finds videos of a specific height in pixels. So height:480 finds videos <br /> that are 480 pixels tall.<br /><br /><br /><br /><br /> duration<br /><br /><br /> Finds clips of a certain length in seconds. As you'd expect, duration:>30 <br /> limits results to videos longer than 30 seconds, and duration:<30 limits <br /> results to videos that are shorter than 30 seconds.<br /><br /><br /><br /><br /> tld<br /><br /><br /> Finds videos that are hosted on a specific top-level domain (a phrase for <br /> which the keyword tld is an abbreviation), such as .org, .com, .gov, .edu, <br /> or a specific county top-level domain, such as .jp for Japan.<br /><br /><br /><br /><br /> fromtld<br /><br /><br /> Narrows results to videos that have been referenced on a page at a <br /> specific top-level domain, because some sites can link to videos on other <br /> domains. So even though a particular video might reside at .com address, <br /> Yahoo! might have indexed the video via a page at an .edu domain that <br /> linked to the video. The syntax fromtld:edu finds videos that have been <br /> referenced in pages at .edu domains.<br /><br /><br /><br /><br /> site<br /><br /><br /> Searches for videos at a specific site. The syntax site:nasa.gov limits <br /> results to videos hosted at http://www.nasa.gov/.<br /><br /><br /><br /><br /> fromsite<br /><br /><br /> Limits search results to pages that reference videos at the specified <br /> site. While the site specified might not host videos, this special syntax <br /> still ensures that pages with links to videos from the site are included.<br /><br /><br /><br /><br /> title<br /><br /><br /> Limits search results to video clips with specific words in the video's <br /> filename. A search with title:rover returns only videos with rover in the <br /> filename or link text.<br /><br /><br /><br /><br /> fromtitle<br /><br /><br /> Limits results to words in a referring document's title. The syntax <br /> fromtitle:rover finds videos that have been referenced on pages with rover <br /> in the filename, even though the word rover might not appear in the name <br /> of the video file.<br /><br /><br /> A final special keyword, aspect, lets you limit search results to video <br /> files with a specific aspect ratio. The aspect ratio refers to a video's <br /> display width divided by its height. A standard television screen is <br /> almost square, but its width is a bit longer than its height. The aspect <br /> ratio of a standard television screen is noted as 4:3. The newer <br /> high-definition television screens are much longer than they are wide, and <br /> their aspect ratio is noted as 16:9. Naturally, the video for each of <br /> these devices matches the proper aspect ratio.<br /><br /><br /> The aspect keyword expects a standard single integer to represent an <br /> aspect ratio, so you'll need to do a little math before you use it. The <br /> formula is the video width multiplied by 100, then divided by the height <br /> and rounded down if necessary. To make things easy, here are the most <br /> common aspect ratios, along with the computed value you'd use with the <br /> aspect keyword:<br /><br /><br /> Table 1-4. <br /><br /><br /> Aspect ratio<br /><br /> Computed value<br /><br /><br /> Television (4:3)<br /><br /> 133<br /><br /><br /> Computer monitors (5:4)<br /><br /> 125<br /><br /><br /> Widescreen movies and HDTV (16:9)<br /><br /> 177<br /><br /><br /><br /><br /><br /> For example, using aspect:177 in a video search query limits the results <br /> to files that are in a widescreen format.<br /><br /><br /><br /><br /> You can also use the special video syntax with the Yahoo! <br /> Video Web Services if you want programmatic access to video <br /> search results. Read the full documentation for the service at <br /> http://developer.yahoo.net/video/V1/videoSearch.html.<br /><br /><br /><br /><br /><br /><br /> You can use these special syntax elements in combination to build some <br /> fairly sophisticated queries. Yahoo! Movies (http://movies.yahoo.com/) <br /> hosts hundreds of movie previews and clips, and you can find a full <br /> listing at http://movies.yahoo.com/trailers. The site doesn't offer <br /> thumbnail browsing of its archive, but you can easily see thumbnails of <br /> the clips available with an advanced Yahoo! Video Search. Search for <br /> site:yahoo.com matrix to see thumbnails of video clips and trailers from <br /> the three Matrix movies.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 12. Streamline Browsing with the Yahoo! Toolbar<br /><br /><br /><br /><br /><br /> The Yahoo! Toolbar integrates Yahoo! with your web browser, letting you <br /> search, customize features, and access your mail from the browser at all <br /> times.<br /><br /><br /> The Yahoo! Toolbar is a browser extension offered by Yahoo! that <br /> integrates many of Yahoo!'s features with your web browser. After <br /> installing the toolbar, you'll find an extra row of buttons in your <br /> browser, as shown in Figure 1-32.<br /><br /><br /><br /><br /> Figure 1-32. The Yahoo! Toolbar<br /><br /><br /><br /><br /><br /> The toolbar contains buttons that perform Yahoo!-specific functions and a <br /> search form for quick access to Yahoo! searching. The toolbar can provide <br /> one-click access to all of your pages at Yahoo!, including your mail, <br /> groups, calendars, address book, and stock quotes. The toolbar is <br /> completely customizable, and you can choose which buttons and Yahoo! <br /> features are available on the toolbar. Because Yahoo! makes most of its <br /> features available via the toolbar, you can tailor your toolbar to suit <br /> the way you use Yahoo!.<br /><br /><br /> 1.13.1. Installation<br /><br /><br /> To install the Yahoo! Toolbar, point your browser to <br /> http://toolbar.yahoo.com/ and click the orange Download button. From <br /> there, you'll find a page with instructions about downloading and <br /> installing the toolbar. At the time of this writing, the toolbar is <br /> available only for Internet Explorer, but there is a beta (i.e., testing) <br /> version available for Mozilla Firefox. Because the program is a browser <br /> extension rather than a traditional application, the download and <br /> installation will happen within the browser window. You'll need to approve <br /> some security requests along the way, and Yahoo! has laid out all of the <br /> steps to take on its site. Firefox requires you to restart the browser to <br /> see the toolbar, but Internet Explorer doesn't.<br /><br /><br /><br /><br /> You can uninstall the Yahoo! Toolbar at any time by choosing <br /> Uninstall from the Toolbar Settings button.<br /><br /><br /><br /><br /><br /><br /> Once the toolbar is installed, it will try to log in with your Yahoo! ID. <br /> If you are currently logged into Yahoo!, or if you have asked Yahoo! to <br /> "remember you," the toolbar should display the introductory Choose Buttons <br /> and Welcome Tour buttons. Otherwise, click the Sign In button and enter <br /> your Yahoo! ID and password.<br /><br /><br /> The Welcome Tour is a quick Flash demo that shows how you can use the <br /> toolbar. Select Choose Buttons to pick which buttons you'd like to see. If <br /> you don't see the Choose Buttons option, click the Toolbar Settings button <br /> shown in Figure 1-33 and choose Add/Edit Buttons…from Personal Options.<br /><br /><br /><br /><br /> Figure 1-33. The options under the Yahoo! Toolbar Settings button<br /><br /><br /><br /><br /><br /> Once you click Choose Buttons or Add/Edit Buttons…, you'll find a page in <br /> your browser like the one shown in Figure 1-34, which will let you check <br /> off the features you'd like to have in the toolbar.<br /><br /><br /><br /><br /> Figure 1-34. The Customize Yahoo! Toolbar page<br /><br /><br /><br /><br /><br /> There are over 60 different buttons you can choose from, and your choices <br /> should depend on which parts of Yahoo! you use the most.<br /><br /><br /> 1.13.2. Features<br /><br /><br /> You can think of the Yahoo! Toolbar as a portal to everything Yahoo! <br /> offers. In fact, looking at the various buttons you can add to the Yahoo! <br /> Toolbar is a great way to get an overview of all the features that Yahoo! <br /> offers. Many of the buttons simply provide a link to a particular section <br /> of Yahoo!, but here are a few that offer some features particularly suited <br /> for the toolbar.<br /><br /><br /> 1.13.2.1. Get notification of new email.<br /><br /><br /> The Yahoo! Mail button listed under Personal Tools on the Customize Yahoo! <br /> Toolbar page lets you quickly compose mail, access your address book, and <br /> send the current page to someone via email. Figure 1-35 shows the list of <br /> options with the Yahoo! Mail button.<br /><br /><br /> Even without the mail button enabled, you'll receive an alert when you <br /> have new mail at your Yahoo! Mail address. A button like the one shown in <br /> Figure 1-36 will appear, letting you know how many messages you have <br /> waiting for you. You can click the message count to go directly to Yahoo! <br /> Mail.<br /><br /><br /><br /><br /> Figure 1-35. The Yahoo! Mail button options<br /><br /><br /><br /><br /><br /><br /><br /> Figure 1-36. The Yahoo! Toolbar Mail Alert<br /><br /><br /><br /><br /><br /> 1.13.2.2. Manage bookmarks.<br /><br /><br /> If you've already discovered the convenience of storing bookmarks at <br /> Yahoo!, you'll appreciate the convenience that the Bookmarks button <br /> provides. You can enable the Bookmarks button by checking Internet <br /> Explorer Bookmarks under Search & Navigation on the Customize <br /> Yahoo!Toolbar page. The Yahoo! Toolbar lets you add the current page in <br /> the browser to your Yahoo! bookmarks with one click. In addition, you'll <br /> have one-click access to all of your Yahoo! bookmarks, as shown in Figure <br /> 1-37.<br /><br /><br /><br /><br /> Figure 1-37. Yahoo! Toolbar bookmarks<br /><br /><br /><br /><br /><br /> The nice feature of using Yahoo! bookmarks instead of browser bookmarks is <br /> that they'll be available on any browser and across multiple computers. If <br /> you install the Yahoo! Toolbar on your home computer as well as your <br /> computer at work, you'll have the same bookmarks in both places.<br /><br /><br /> 1.13.2.3. Add content to My Yahoo!.<br /><br /><br /> If you enable the My Yahoo! button by choosing it on the Customize Yahoo! <br /> Toolbar page, found under Personal Tools, you'll have one-click access to <br /> your personalized news portal. Yahoo! will also analyze every page you <br /> visit, looking for the ability to subscribe to its related RSS or Atom <br /> feed. If the page offers a feed, you'll find a blue plus symbol next to <br /> the My Yahoo! button on the toolbar (see Figure 1-38).<br /><br /><br /><br /><br /> Figure 1-38. The Yahoo! Toolbar Subscribe to RSS button<br /><br /><br /><br /><br /><br /> Clicking the Subscribe to RSS button takes you to a page at Yahoo! that <br /> asks you to confirm the addition of the news source to your personalized <br /> My Yahoo! page. From then on, you'll see headlines from the site when <br /> something new is added.<br /><br /><br /> 1.13.2.4. Block pop-up windows.<br /><br /><br /> The Yahoo! Toolbar includes options for taking care of some common <br /> annoyances. The Internet Explorer version of the Toolbar includes a button <br /> that stops pop-up windows: those annoying ads that open in new browser <br /> windows.<br /><br /><br /><br /><br /> The Firefox browser stops pop-ups by default, so the pop-up <br /> blocker is not included with the Yahoo! Toolbar for Firefox.<br /><br /><br /><br /><br /><br /><br /> Figure 1-39 shows the options for the pop-up-blocking button.<br /><br /><br /><br /><br /> Figure 1-39. The Yahoo! Toolbar pop-up blocker<br /><br /><br /><br /><br /><br /> If you ever want to allow pop-ups from a domain that is using them for a <br /> good cause, you can choose Always Allow Pop-Ups From…and enable them for <br /> the current site.<br /><br /><br /> The pop-up blocker is enabled by default, but you can always disable it by <br /> choosing Toolbar Settings Toolbar Options…and unchecking Pop-Up Blocker.<br /><br /><br /> 1.13.2.5. Enable quick searches.<br /><br /><br /> The most prominent feature of the toolbar is the search form. From any web <br /> page, you can type some text into the form, click enter, and go to the <br /> Yahoo! Search results for that phrase. You can also choose one of the many <br /> search options in the drop-down list shown in Figure 1-40.<br /><br /><br /><br /><br /> Figure 1-40. The Yahoo! Toolbar search form<br /><br /><br /><br /><br /><br /> Another nice feature of the search form lets you highlight some text on <br /> the page, drag it to the form, and release the mouse button. This will add <br /> the highlighted text to the form so you can search with it, saving you <br /> some typing.<br /><br /><br /><br /><br /> If you use Firefox, you're probably already familiar with the <br /> search box in the upper-right corner, which is similar to the <br /> Yahoo! Toolbar search form. The default search engine is <br /> Google, but you can easily select Yahoo! by clicking the <br /> Google icon and choosing the Yahoo! icon from the drop-down <br /> menu.<br /><br /><br /><br /><br /><br /><br /> 1.13.3. Privacy<br /><br /><br /> It's important to keep in mind that the Yahoo! Toolbarlike the Yahoo! web <br /> siteholds some of your personal information. The Yahoo! Toolbar provides <br /> instant access to your mail, personalized news sources, and bookmarks. If <br /> you're the only person with access to your browser, this probably isn't a <br /> problem. But if you're in a shared computing environment, there are some <br /> steps you can take to keep your information private.<br /><br /><br /> First, always click the Sign Out button (see Figure 1-41) when you're <br /> finished using the browser.<br /><br /><br /><br /><br /> Figure 1-41. The Yahoo! Toolbar Sign Out button<br /><br /><br /><br /><br /><br /> If you don't see a Sign Out button, you might already be signed out. You <br /> can also enable the Sign Out button by checking Sign Out under Other on <br /> the Customize Yahoo! Toolbar page. Adding this button and using it when <br /> you're finished browsing will ensure that your personal information is not <br /> available to others using the computer. For good measure, you can click <br /> the Refresh Toolbar option under the Toolbar Settings button to make sure <br /> all traces of your Yahoo! ID have been removed for the next user. <br /> Refreshing the toolbar manually updates the status of all buttons for the <br /> current user. Once you have logged out and refreshed the toolbar, your <br /> personal button choices will not appear on the toolbar.<br /><br /><br /> The Yahoo! Toolbar also tracks recent searches to keep them handy for <br /> references. You might not want all other users to know that you searched <br /> for athlete's foot earlier in the day, so you can either clear searches or <br /> completely disable the feature. To get rid of the stored searches, click <br /> the Toolbar Settings button and choose Clear Recent Searches. To disable <br /> the feature, choose the Toolbar Settings Toolbar Options…and you'll see <br /> the form shown in Figure 1-42.<br /><br /><br /><br /><br /> Figure 1-42. The Yahoo! Toolbar Options dialog<br /><br /><br /><br /><br /><br /> Under Search Box, uncheck the Remember Recent Searches option, and the <br /> Yahoo! Toolbar will lose its memory. Optionally, you could check the <br /> Auto-clear option to remove recent searches anytime you close the browser. <br /> At the time of this writing, the Yahoo! Toolbar Options form is available <br /> only with the Internet Explorer toolbar, so Firefox users have to get by <br /> with the Clear Recent Searches option.<br /><br /><br /> This hack just scratches the surface of what's available through the <br /> Yahoo! Toolbar. With quick access to Yahoo! features as you browse other <br /> sites, you will find efficient ways to share information and take <br /> advantage of more of Yahoo!'s applications.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 13. Customize the Firefox Quick Search Box<br /><br /><br /><br /><br /><br /> Though Yahoo! Web Search is a default option in the Firefox search box, <br /> with some quick coding you can add many other Yahoo! Search types.<br /><br /><br /> If you use the Firefox web browser (available at <br /> http://www.mozilla.org/products/firefox), you're probably already aware of <br /> the useful search box in the upper-right corner. From any page, at any <br /> time, you can simply type a query into the box and press Enter to bring <br /> the search page up in the browser. Though Google is the default search <br /> engine, you can click the arrow to choose another search engine, as shown <br /> in Figure 1-43.<br /><br /><br /><br /><br /> Figure 1-43. Firefox search box options<br /><br /><br /><br /><br /><br /> Yahoo! Web Search is a default option, and once you choose Yahoo! from the <br /> drop-down list, it will stay your top choice until you change it again.<br /><br /><br /> The nice thing about this list of potential search engines is that you can <br /> add any search engine of your choice. In fact, Firefox offers an Add <br /> Engines…option that takes you to a page with more search choices you can <br /> install with a few clicks. The New Search Engines section contains a page <br /> (http://mycroft.mozdev.org/quick/yahoo.html) full of over 30 different <br /> Yahoo!-related searches you can add to the Firefox search box. These are <br /> searches that others have found useful and decided to share with the <br /> larger Mozilla community (Mozilla is the technology behind Firefox). The <br /> specialty Yahoo! searches include everything from searching Yahoo! <br /> Auctions and searching Yahoo! in different countries, to the Yahoo! Oxford <br /> Shakespeare reference. If you find yourself constantly looking for pithy <br /> quotes from The Tempest, adding this option to the Firefox search box <br /> could be the stuff dreams are made of.<br /><br /><br /> To add a search engine from this Mozilla page, simply click the name of <br /> the search engine you'd like to add. A pop-up box will ask you to confirm <br /> your choice; click OK, and the new choice will be available in the Firefox <br /> search box menu. Behind the scenes, Firefox has copied a small .src file <br /> and icon to the searchplugins directory of the Firefox installation. This <br /> text file defines how the search works.<br /><br /><br /> If you don't find the search of your dreams at the Mozilla page, it's <br /> fairly easy to build your own specialty Yahoo! search and add it to your <br /> list of available search engines. You just need a simple text editor to <br /> create the search engine text file, and an eye for spotting patterns in <br /> search URLs.<br /><br /><br /> 1.14.1. The Code<br /><br /><br /> Maybe you're a fan of the Yahoo! Image Search (http://images.yahoo.com/) <br /> and you'd like to be able to search for images quickly from Firefox. The <br /> first step in creating a custom entry is to perform a search and take a <br /> look at the URL. For this example, browse to http://images.yahoo.com/, <br /> type Shakespeare into the search form, and click Search Images. You should <br /> receive a page full of various pictures of Shakespeare, but take a look at <br /> the URL in the address bar. The relevant pieces of the URL include the <br /> images.search.yahoo.com domain, the images file, and the p variable, which <br /> is set to the search query:<br /><br /><br /> http://images.search.yahoo.com/search/images?p=shakespeare<br /><br /><br /><br /><br /> Now that you know how Yahoo! Image Search URLs are constructed, you can <br /> write the file that will tell Firefox where to send search requests. <br /> Create a file called yahoo_image.src in a plain-text editor such as <br /> Notepad, and add the following code:<br /><br /><br /> # Yahoo! Image Search<br /> #<br /> # Created April 16, 2005<br /><br /><br /> <SEARCH<br /> version="7.1"<br /> name="Yahoo! Image Search"<br /> description="Search for images at Yahoo!"<br /> method="GET"<br /> action="http://images.search.yahoo.com/search/images" ><br /><br /><br /> <input name="p" user><br /><br /><br /> </search> <br /><br /><br /><br /><br /> As you can see, this quick file begins with an opening <SEARCH> tag that <br /> holds the name of the search, and a brief description. Everything before <br /> the question mark in the search results URL becomes the value of the <br /> action attribute. The input tag lets Firefox know the value should come <br /> from user input and that it should be named p, as in the Yahoo! Image URL.<br /><br /><br /> 1.14.2. Running the Hack<br /><br /><br /> Save the file and add it to the Firefox searchplugins directory, usually <br /> located at C:\Program Files\Mozilla Firefox\searchplugins on Windows and <br /> at /Applications/Mozilla.app/Contents/MacOS/searchplugins on Mac OS X. <br /> You'll also need an icon for the search, and because Firefox comes with a <br /> Yahoo! search option, you can simply copy the existing yahoo.gif file from <br /> the searchplugins directory and name it with the same prefix as your new <br /> Yahoo! Image Search text fileyahoo_image.gif, in this example.<br /><br /><br /> Once you restart Firefox, you'll find a new option in the search list <br /> called Yahoo! Image Search. Choose this option and type the original <br /> Shakespeare query in the search box. If all goes well, you should see a <br /> page of Shakespeare images like the one shown in Figure 1-44.<br /><br /><br /><br /><br /> Figure 1-44. Yahoo! Image Search results via the Firefox search box<br /><br /><br /><br /><br /><br /> If you find yourself using a particular Yahoo! search time and again, you <br /> might be able to speed up your access to the search with an eye for search <br /> URLs and some quick text editing.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 14. Spot Trends with Yahoo! Buzz<br /><br /><br /><br /><br /><br /> Find out which pop culture phenomenon is on the way in or out by looking <br /> at trends in search queries.<br /><br /><br /> Everywhere we look in the media, there are lists of bestsellers that can <br /> tell us what's hot at the moment. People watch the top-grossing movies <br /> like they'd watch the stock market, and best-selling books are always a <br /> topic of conversation. Yahoo! has its own way of tracking what's hot: by <br /> looking at the most common phrases people search for. If Yahoo! users are <br /> suddenly searching for singer Gwen Stefani more often than for Britney <br /> Spears, that shows a shift in interest or popularity.<br /><br /><br /> 1.15.1. Determining Current Leaders and Movers<br /><br /><br /> Yahoo! tracks exactly these kinds of trends at the Yahoo! Buzz Index <br /> (http://buzz.yahoo.com/). When you browse the Buzz Index, you'll find <br /> several Top Movers Charts, separated into categories such as TV, Music, <br /> Sports, Movies, Actors, Video Games, and overall queries. Each chart has <br /> the top 15 search queries with the greatest percentage increase for that <br /> particular day. These charts are a quick snapshot of which queries are <br /> gaining the most ground.<br /><br /><br /> At the bottom of each chart, you'll find a "View complete chart…" link, <br /> which you can click to compare the top Movers with the Leaders. Instead of <br /> tracking the greatest change in terms of percentage, the Leaders chart <br /> shows you the top search queries for that category. Figure 1-45 shows the <br /> Leaders and Movers lists, side by side. The current champs (Leaders) are <br /> on the left, and the challengers (Movers) are on the right.<br /><br /><br /><br /><br /> Figure 1-45. The overall Leaders and Movers at Yahoo! Buzz Index<br /><br /><br /><br /><br /><br /> Each entry on the Leaders chart shows the rank, whether the term is <br /> gaining or losing ground, how many points the term has moved in the last <br /> day, the number of days the term has been on the chart, and the overall <br /> buzz score. According to Yahoo!, a single buzz point is what 0.001% of <br /> Yahoo! users were searching for on a particular day. So the buzz score of <br /> 370 for the top entry in Figure 1-45 means that 0.37% of all Yahoo! users <br /> searched for American Idol on that day. With millions of users, that small <br /> percentage means thousands of people.<br /><br /><br /> From the left side of the page, you can click the Decliners link under <br /> Overall to list terms that have dropped over the last day. Many of the <br /> entries are related to news stories that were on top of people's minds the <br /> previous week.<br /><br /><br /> The terms are placed into categories like TV, Music, and Sports by Yahoo! <br /> Buzz Index editors, and general terms like television or football are <br /> filtered out of the results. The editors also exclude terms that aren't <br /> appropriate for children.<br /><br /><br /> If you don't plan on visiting the Yahoo! Buzz Index every day to see the <br /> movers and shakers, you might want to subscribe to the Buzz Index Weekly <br /> Report by browsing to <br /> http://subscribe.yahoo.com/subscribe?.optin=ybz&.src=ybz. Once subscribed, <br /> you'll receive an email every Sunday with the hottest search trends from <br /> the previous week. The report is compiled by Yahoo! editors and sometimes <br /> contains a slice of reporting that doesn't show up on the leader boards. <br /> For example, the April 3, 2005, report included a look at the most popular <br /> diet searches and found that Weight Watchers was beating out South Beach <br /> Diet and Atkins Diet, even though these terms weren't high enough to be in <br /> the overall search. You can also stay on top of the Yahoo! Buzz Loga <br /> frequently updated look at what's hot by Yahoo! Editorsby subscribing to <br /> the Buzz Log RSS feed (http://buzz.yahoo.com/feeds/buzzlog.xml) in your <br /> favorite newsreader.<br /><br /><br /> 1.15.2. Going Back in Time<br /><br /><br /> If you're interested in what was popular at some point in the past, you <br /> can take a stroll through the Yahoo! Buzz Log archives. At the time of <br /> this writing, Yahoo!'s archives go back to June 20, 2004. To find the <br /> page, enter this search query at http://search.yahoo.com/:<br /><br /><br /> site:buzz.yahoo.com "June 20, 2004"<br /><br /><br /><br /><br /> The Yahoo! Buzz Log archives are based on Sundays, so you can change the <br /> date to any Sunday you'd like to see between June 20, 2004, and the <br /> present.<br /><br /><br /><br /><br /> Your Yahoo! Calendar at http://calendar.yahoo.com/ in monthly <br /> view works well for finding any given Sunday.<br /><br /><br /><br /><br /><br /><br /> So if you'd like to find out what was on people's minds in mid July of <br /> 2004, you could search like this:<br /><br /><br /> site:buzz.yahoo.com "July 11, 2004"<br /><br /><br /><br /><br /> Or you could create the archive URL yourself in this format:<br /><br /><br /> http://buzz.yahoo.com/buzz_log/yyyymmdd/<br /><br /><br /><br /><br /> So the URL for the Buzz Log archive for July 11, 2004, would be:<br /><br /><br /> http://buzz.yahoo.com/buzz_log/20040711/<br /><br /><br /><br /><br /> Unfortunately, Yahoo! doesn't provide access to past charts, but you can <br /> get the Yahoo! Editors' takes on what was happening by visiting these <br /> archives.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 15. Find Hot Technologies at the Buzz Game<br /><br /><br /><br /><br /><br /> The Buzz Game lets tech geeks speculate about where their industries are <br /> headed, and you can use their insider knowledge to spot tech trends.<br /><br /><br /> If you follow technology trends like some people follow the stock market, <br /> you can put your knowledge to work by placing your bets on where <br /> technology is headed at the Yahoo! Buzz Game <br /> (http://buzz.research.yahoo.com/). But even if you can't tell an iPod from <br /> a Typepad, the Yahoo! Buzz Game can help you make sense of the technology <br /> landscape.<br /><br /><br /> A joint venture between Yahoo! Research and O'Reilly Media, Inc., the <br /> Yahoo! Buzz Game is a fantasy stock market for technology terms. The <br /> market attempts to predict what's going to be hot, by letting tech <br /> enthusiasts "buy" and "sell" technology terms. If the value of a <br /> particular tech term goes up, the score of players holding that term goes <br /> up. The players with the best scores can win prizes.<br /><br /><br /> The Buzz Game is split into around 50 different markets, ranging from <br /> specific types of hardware and software, such as Portable Media Devices <br /> and Operating Systems, to less tangible ideas, such as Annoyances (which <br /> lets people bet on pop-up advertising or email spam).<br /><br /><br /> 1.16.1. Spotting Trends<br /><br /><br /> Beyond letting you place bets and play the game, the Yahoo! Buzz Game site <br /> gives you a great snapshot of the current state of technology in a <br /> particular industry. For example, click Markets at the top of the home <br /> page and browse the categories for Portable Media Devices. At a glance, <br /> you can see the top contenders in the portable media gadget space. Figure <br /> 1-46 shows the relative market prices for various MP3 players in April <br /> 2005, with the iPod clearly ahead of the pack.<br /><br /><br /> Clicking through each entry in a particular market, you can get a sense of <br /> how game players feel about each product's chances for success. If you <br /> browse through the items listed under Rumor Mill, you'll see products that <br /> don't exist yet and what tech-heads are predicting about their chances at <br /> existence.<br /><br /><br /> Each company or product has a detail page, similar to a stock-tracking <br /> page, with the current price, its history, and overall buzz score (see <br /> Figure 1-47).<br /><br /><br /><br /><br /> Figure 1-46. The Portable Media Devices market at the Buzz Game<br /><br /><br /><br /><br /><br /><br /><br /> Figure 1-47. The Flickr detail page at the Yahoo! Buzz Game<br /><br /><br /><br /><br /><br /> The buzz score is derived via the same methodology used for the Yahoo! <br /> Buzz Index [Hack #14] scores, and it represents the number of searches for <br /> that particular term. The detail page includes related news about a <br /> particular technology, thanks to Yahoo! News, and, if you're playing <br /> along, a form that lets you buy or sell shares.<br /><br /><br /> 1.16.2. Buzz Game API<br /><br /><br /> If you'd like to do a bit of your own fantasy market analysis, Yahoo! <br /> offers all of the Buzz Game data as XML. There are several ways to access <br /> the data, including two files that offer most of the information in one <br /> place:<br /><br /><br /><br /><br /> All Buzz Game data in one file<br /><br /><br /> Available at http://buzz.research.yahoo.com/bk/rest/allinfo.xml, this file <br /> includes data for every market and stock. Each stock entry includes the <br /> stock's internal ID, price, buzz score, and number of shares, and every <br /> market includes the market capitalization.<br /><br /><br /><br /><br /> All stock prices in one file<br /><br /><br /> This is a simplified version of the above file, and it includes prices of <br /> each stock organized by market. This file is at <br /> http://buzz.research.yahoo.com/bk/rest/prices.xml.<br /><br /><br /> Another way to find data about individual stocks is to create request URLs <br /> that contain the stock symbol and the symbol for the market that stock <br /> belongs to. Here's the URL format for looking up individual stocks:<br /><br /><br /> http://buzz.research.yahoo.com/bk/rest/info.xml?marketsymbol=insert market <br /><br /><br /><br /><br /> symbol&stocksymbol=insert stock symbol<br /><br /><br /><br /><br /> So if you'd like to find out what the iPod is trading at, you can visit <br /> the Portable Media Devices market detail page <br /> (http://buzz.research.yahoo.com/bk/market/market.html?_mid=6928) and find <br /> the symbol for that market (PORTMEDIA) at the top of the page. A bit <br /> further down the page, you'll see that the symbol for the individual iPod <br /> stock is, appropriately, IPOD. Knowing these two symbols, you can get an <br /> XML representation of the price, buzz score, and number of shares <br /> available with the following URL:<br /><br /><br /> http://buzz.research.yahoo.com/bk/rest/info.xml?marketsymbol=PORTMEDIA&<br /><br /><br /><br /> stocksymbol=IPOD<br /><br /><br /><br /><br /> Finally, you can also access individual stocks via their internal ID <br /> number with the following URL format:<br /><br /><br /> http://buzz.research.yahoo.com/bk/rest/info.xml?stockid=insert stock ID<br /><br /><br /><br /><br /> To find a stock ID for any particular stock, you'll first need to look up <br /> the ID via one of the XML files.<br /><br /><br /> 1.16.3. Graphing Markets<br /><br /><br /> One potential use of the Buzz Game API is to create your own charts and <br /> graphs to spot trends in the fantasy market. Using a bit of Perl to move <br /> the Buzz Game data into Excel, you can don your green visor and start <br /> doing your own analysis about where to place your bets.<br /><br /><br /> 1.16.3.1. The code.<br /><br /><br /> To use this code, you'll need a copy of LWP::Simple, for fetching the Buzz <br /> Game page. This script accepts a market symbol, fetches the prices.xml <br /> file, and loops through the file looking for the specific market. Once the <br /> script finds the market, it prints the stock names and prints a <br /> comma-separated value list suitable for opening in Excel. To get started, <br /> save the following code to a file called buzz_excel.pl:<br /><br /><br /> #!/usr/bin/perl<br /> # buzz_excel.pl<br /> # Accepts a Buzz Game Market Symbol and returns a CSV<br /> # list of stock prices you can open in Excel.<br /> # Usage: buzz_excel.pl <market symbol><br /> #<br /> # You can find market IDs, and read more about the Buzz Game<br /> # at http://buzz.rsearch.yahoo.com/<br /><br /><br /> use strict;<br /> use LWP::Simple;<br /> use Data::Dumper;<br /><br /><br /> # Grab the incoming market ID <br /> my $msym = join(' ', @ARGV) or die "Usage: buzz_excel.pl <market <br /> symbol>\n";<br /><br /><br /> # Set the request URL<br /> my $buzz_url = "http://buzz.research.yahoo.com/bk/rest/prices.xml";<br /><br /><br /> # Make the request<br /> my $prices = get($buzz_url);<br /><br /><br /> # Find the market<br /> while ($prices =~ m!<Market.*?symbol="$msym" name="(.*?)".*?>(.*?)<br /> </Market>!mgis) { <br /> my $market_name = $1; <br /> print "\"$market_name\"\n\n"; <br /> my $stocks = $2; <br /> while ($stocks =~ m!<Stock.*?symbol="(.*?)" name="(.*?)">\n<Price>(.<br /><br /><br /><br /> *?)</Price>\n</Stock>!mgis) {<br /> my $stock_symbol = $1;<br /> my $stock_name = $2;<br /> my $stock_price = $3;<br /> print "\"$stock_name\",$stock_symbol,$stock_price\n";<br /> }<br /> }<br /><br /><br /><br /><br /> 1.16.3.2. Running the hack.<br /><br /><br /> To run the code, simply call the script from the command line, adding your <br /> relevant market ID and choosing an output file:<br /><br /><br /> perl buzz_excel.pl RUMOR > rumors.csv<br /><br /><br /><br /><br /> If you have a spreadsheet program, you should be able to double-click <br /> rumors.csv to take a look at the data. If you'd like to whip up a snazzy <br /> pie chart, highlight the block of data and start the chart wizard by <br /> selecting Insert Chart…, choosing the pie chart type, and following the <br /> rest of the wizard's steps. You'll end up with a quick visualization of <br /> the market, as shown in Figure 1-48.<br /><br /><br /><br /><br /> Figure 1-48. Buzz Game Rumor Mill market pie chart in Microsoft Excel<br /><br /><br /><br /><br /><br /> At a glance, you can see that the Xbox 360 rumor has the biggest slice of <br /> the pie at the time of this writing (May 2005). This particular analysis <br /> won't tell you where to place your bets in the game, but hopefully it <br /> shows how you can start to play with the data this fantasy market is <br /> generating.<br /><br /><br /> The Yahoo! Buzz Game won't replace traditional market research for <br /> spotting trends, but it's a fun way take the pulse of tech geeks and see <br /> what they're predicting.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 16. Tame Long Yahoo! URLs<br /><br /><br /><br /><br /><br /> With an eye for URLs and the right tools, you can shorten long Yahoo! URLs <br /> when you need to send them via email.<br /><br /><br /> Most of the time, we're all surfing the Web in virtual isolation. It's <br /> just you and the computer, and the last thing on your mind is the length <br /> of a URL at a page you're visiting. But as soon as you want to share the <br /> piece of the Web you're viewing with someone else, the length of a URL <br /> becomes important.<br /><br /><br /> Because email programs wrap text at 72 characters (for easy reading), any <br /> URL that's longer could be broken. A broken URL means someone on the other <br /> end of the message won't be able to see the page you've sent themor that <br /> they will have to spend a minute or two pasting the URL together in <br /> Notepad. And imagine trying to handwrite a note to someone that includes <br /> some of the URLs you stumble across!<br /><br /><br /> 1.17.1. Trimming Yahoo! URLs<br /><br /><br /> Yahoo! has a lot of great content to share with others, but some of the <br /> URLs are definitely too long to send via email. Here's a Yahoo! Local URL <br /> for a page that shows a list of coffee shops in Sebastopol, CA:<br /><br /><br /> http://local.yahoo.com/results;_ylt=AvyPaC0wOiCme6J1PYb56tSHNcIF;_<br /><br /><br /><br /> ylu=X3oDMTBtbGZ2dXFpBF9zAzk2NjEzNzY3BHNlYwNzZWFyY2g-?stx=coffee&<br /><br /><br /><br /> csz=Sebastopol%2C+CA&fr=<br /><br /><br /><br /><br /> Those 154 characters in the URL are definitely past the 72-character safe <br /> zone. If you take a look at the URL, you can see some variable/value pairs <br /> that contain the relevant information. The string ?stx=coffee looks <br /> important, as does csz=Sebastopol%2C+CA. But the rest of the URL looks <br /> like gibberish.<br /><br /><br /><br /><br /> It's important to note that what looks like gibberish is <br /> actually useful information to Yahoo!, but it's not useful to <br /> you when you're trying to share links, so you can cut it out.<br /><br /><br /><br /><br /><br /><br /> Cutting the garbage characters out of the URL will give you something more <br /> manageable:<br /><br /><br /> http://local.yahoo.com/results?stx=coffee&csz=Sebastopol%2C+CA<br /><br /><br /><br /><br /> If the area you want to search is small enough, you can even use a Zip <br /> Code instead of the city and state combination:<br /><br /><br /> http://local.yahoo.com/results?stx=coffee&csz=95472<br /><br /><br /><br /><br /> The 51 characters in this URL are well within the safe zone, and the URL <br /> points to exactly the same page. If you frequently find yourself sharing <br /> pages from Yahoo! Local, you might want to pick up a bookmarklet by Brian <br /> Cantoni (available at http://www.cantoni.org/2005/06/06/ylocal) that <br /> automates the process of removing the garbage characters. Drag the <br /> bookmarklet link to your toolbar, and click it anytime you want to share a <br /> link to Yahoo! Local. The bookmarklet opens a new email message with a <br /> shortened URL as the text of the message. From there, you can compose your <br /> message and share the link without fear of a broken URL.<br /><br /><br /> Even URLs that seem short enough can be just over the limit. Here's a page <br /> of Yahoo! Search results for Brevity is the soul of wit:<br /><br /><br /> http://search.yahoo.com/search?ei=UTF-8&fr=sfp&p=Brevity+is+the+soul+of+wit<br /><br /><br /><br /><br /> The 75 characters in this URL are barely over the limit. But you can do <br /> some trimming here to bring it back under 72 characters. By cutting the <br /> URL to its bare essentials, you can get the same search results page down <br /> to 59 characters:<br /><br /><br /> http://search.yahoo.com/search?p=Brevity+is+the+soul+of+wit<br /><br /><br /><br /><br /> When you're ready to share a URL, keep an eye out for ways to trim the URL <br /> down to size. But there will be times when the only option you have is a <br /> URL-trimming service.<br /><br /><br /> 1.17.2. URL-Trimming Services<br /><br /><br /> The scourge of long URLs is so rampant on the Web that several free <br /> services have appeared to help you share even the most insanely long URLs <br /> with others. To see how these services can help, here's an example of a <br /> Yahoo! Maps URL that points to a page with driving directions from San <br /> Francisco, CA, to the O'Reilly offices in Sebastopol, California:<br /><br /><br /> http://maps.yahoo.com/dd_result?newaddr=&taddr=1005+Gravenstein+Hwy+N&<br /><br /><br /><br /> csz=San+Francisco%2C+CA&country=us&tcsz=Sebastopol+CA&tcountry=us<br /><br /><br /><br /><br /> As you can see, this 135-character URL is dense with information. There's <br /> nothing extraneous we can strip out to get the same information. This is <br /> where TinyURL.com can help. Copy any long URL you'd like to abbreviate and <br /> paste it into the form on the front page at http://tinyurl.com/. Click the <br /> Make TinyURL! button, and the next page will give you an abbreviated URL, <br /> like this:<br /><br /><br /> http://tinyurl.com/b356b<br /><br /><br /><br /><br /> These 24 characters are well within the safe zone and definitely won't <br /> break in an email. Another service, available at http://shorl.com/, <br /> produces the following URL:<br /><br /><br /> http://shorl.com/disaprigrohegi<br /><br /><br /><br /><br /> Each of these services stores the long URL on its server, assigns the URL <br /> a random character string, and redirects to that long URL when someone <br /> visits the short address. Shorl.com even provides some usage statistics, <br /> so you can see how many people have used the shortened URL.<br /><br /><br /> There are some drawbacks to using these third-party services. The person <br /> you're sharing the link with won't know what site they're actually going <br /> to visit. This might make for some fun practical jokes, but it's always <br /> better to be as direct as possible when sharing URLs with people. Also, <br /> the longevity of the link isn't guaranteed. If TinyURL.com or Shorl.com <br /> goes out of business tomorrow, your link will fail. Using redirection <br /> services like these isn't the best choice if you're going to print a URL <br /> in a book, for example. But for casual use, these services are a good way <br /> to share long URLs without annoying the person on the other end.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 17. Opt Out of Advertiser Cookies<br /><br /><br /><br /><br /><br /> Advertisers on Yahoo! might set browser cookies to track patterns, but you <br /> can tell them you'd rather not be tracked.<br /><br /><br /> Browser cookies are an important piece of web technology that sites like <br /> Yahoo! rely on to give you a personalized experience at their site. <br /> Without cookies, Yahoo! wouldn't be able to let you choose your own news <br /> sources at My Yahoo!, watch your favorite stocks at Yahoo! Finance, or <br /> even send email with Yahoo! Mail. The cookie itself is simply a small bit <br /> of text that resides on your computer. When the cookie is set by a site <br /> such as Yahoo!, only that site can access the cookie's text in the future. <br /> The cookie lets Yahoo! know that a particular user is browsing its site, <br /> and Yahoo! can bring up saved preferences and settings for that particular <br /> user for future visits.<br /><br /><br /> 1.18.1. Cookies at Yahoo!<br /><br /><br /> Cookies aren't inherently good or bad; such a judgment just depends on how <br /> they're used. You should be aware of how cookies are used, so that you can <br /> decide for yourself whether you want them to be set on your computer. You <br /> can view Yahoo!'s privacy policy regarding its use of cookies at <br /> http://privacy.yahoo.com/.<br /><br /><br /> In addition to the cookies that Yahoo! sets in order to remember your <br /> settings, Yahoo! allows other companies to set cookies through its web <br /> site. One of the ways Yahoo! makes money is through advertising, and <br /> Yahoo! sells sections of its pages to other companies. These other <br /> companies (called third parties) might set cookies that are in no way <br /> related to your Yahoo! account. In addition, these cookies do not have to <br /> follow the guidelines in Yahoo!'s privacy policy. This means that any <br /> advertiser or advertising network on Yahoo! might have its own privacy <br /> policy you should be aware of. Yahoo! lists more information about this <br /> practice on their Third Party and Affiliate Cookies on Yahoo! page <br /> (http://privacy.yahoo.com/privacy/us/adservers/details.html).<br /><br /><br /> Most of these third-party cookies are probably being used to track <br /> patterns in Yahoo! usage. If a company has an advertisement on Yahoo! <br /> Finance, it might also want to know if those users are visiting Yahoo! <br /> Mail. These broad usage patterns help companies refine and target their <br /> campaigns without tracking any one person specifically. However, if you <br /> aren't thrilled with the idea of being trackedeven in a general wayacross <br /> the sites you use, most of these advertising companies give you a way out.<br /><br /><br /> 1.18.2. Opting Out<br /><br /><br /> Many advertising networks offer the ability to opt out of cookie-related <br /> monitoring. By visiting a special page on the advertiser's site, you allow <br /> the advertiser to set a cookie on your machine. Instead of tracking your <br /> movements, this opt-out cookie tells the advertiser that you don't want to <br /> participate. The next step is simply finding this page on all of Yahoo!'s <br /> third-party advertisers and setting it.<br /><br /><br /> Luckily, Yahoo! keeps a list of its advertisers at <br /> http://privacy.yahoo.com/privacy/us/adservers/details.html. When you bring <br /> the page up in your browser and scroll down to the section labeled Opting <br /> Out of Third Party Cookies, you'll find a list of companies that are <br /> currently advertising at Yahoo! Unfortunately, Yahoo! doesn't go the next <br /> step and provide a link to each company's opt-out page, but why not use <br /> Yahoo! Web Search to help you find them?<br /><br /><br /> At the time of this writing, the top company on the list is 24/7 Media, <br /> Inc. and their URL is http://www.247realmedia.com/. With the URL in hand, <br /> you can construct a special query to search their site for the special <br /> opt-out page. The site: meta keyword will limit a Yahoo! Search to a <br /> particular domain, and the phrase "opt out" will probably appear on the <br /> page I'm looking for. So the particular query for this company is:<br /><br /><br /> site:www.247realmedia.com opt-out<br /><br /><br /><br /><br /> Note that I've removed the http:// prefix from the URL because the site: <br /> meta keyword only works with the domain. And, sure enough, plugging that <br /> query into the form at http://search.yahoo.com/ returns the 24/7 Media, <br /> Inc. Opt-Out page that will set the opt-out cookie in your browser.<br /><br /><br /> You can repeat this process for every company in the list, until you've <br /> opted out of every one of Yahoo!'s advertising partners. Or, if you have <br /> an amazing amount of time to kill, you could use a similar query to find <br /> each company's privacy policy to make sure its cookie-setting policy is <br /> something you agree with, like so:<br /><br /><br /> site:www.247realmedia.com Privacy Policy<br /><br /><br /><br /><br /> If this process seems too time-consuming to follow, there are some ways to <br /> change your browser settings so that it accepts cookies only from Yahoo! <br /> if your browser supports controlling cookies.<br /><br /><br /><br /><br /> Yahoo! tracks its own advertising efforts both on and off <br /> Yahoo! sites through a technology called Web Beacons. These <br /> are invisible images that load in a browser and set cookies. <br /> You can find out more about Yahoo!'s Web Beacons and opt out <br /> at http://privacy.yahoo.com/privacy/us/beacons/details.html.<br /><br /><br /><br /><br /><br /><br /> 1.18.3. Browser Settings<br /><br /><br /> Cookies are handled by web browsers, and you can change how your browser <br /> handles them. The default setting on most browsers simply accepts all <br /> cookies in the background, without any user intervention. This allows a <br /> seamless browser experience, taking advantage of all of the <br /> personalization options that sites like Yahoo! offer.<br /><br /><br /> To get a sense of just how many cookies are flying around behind the <br /> scenes, try changing your browser settings so that you have to approve <br /> every cookie that's set. In Firefox, choose Tools Options… Privacy and <br /> select Ask Me Every Time from the Keep Cookies drop-down menu. Internet <br /> Explorer (IE) users can choose Tools Internet Options Privacy Advanced <br /> Override and then choose Prompt for both First-party Cookies and <br /> Third-party Cookies. With these settings enabled, you'll be asked to <br /> approve every cookie that comes your way with the prompt shown in Figure <br /> 1-49.<br /><br /><br /><br /><br /> Figure 1-49. Cookie prompt in Internet Explorer<br /><br /><br /><br /><br /><br /> As you browse around different sections of Yahoo!, you'll see the cookie <br /> prompt window with both yahoo.com and third-party cookies being set in <br /> various places and you'll have the option to allow or block the cookies. <br /> Keep in mind that blocking cookies set by yahoo.com will negatively affect <br /> your ability to use Yahoo!'s features. Seeing all of these cookie prompts <br /> is an interesting to get a sense of the cookies being set on your <br /> computer, but surfing around with this setting will get tiresome quickly.<br /><br /><br /> Another available option is to allow first-party cookies while blocking <br /> third-party cookies. First party means the cookies are set by the site <br /> you're visiting. For example, if you're at http://mail.yahoo.com/ and you <br /> get a request to set a cookie from yahoo.com, that is a first-party cookie <br /> from the domain you're browsing. But if you're at http://movies.yahoo.com/ <br /> and you get a request to set a cookie from questionmarket.com, that's a <br /> third-party cookie. Both Internet Explorer and Firefox allow you to accept <br /> first-party cookies without question, while blocking all third-party <br /> cookies without question.<br /><br /><br /> To apply this setting in Internet Explorer, go to Tools Internet Options <br /> Privacy and click Advanced. Set the browser to accept first-party cookies <br /> but block third-party cookies, as shown in Figure 1-50.<br /><br /><br /><br /><br /> Figure 1-50. Internet Explorer Advanced Privacy Settings<br /><br /><br /><br /><br /><br /> Click OK to save your settings.<br /><br /><br /> In Firefox, go to Tools Options… Privacy and check the box that says "for <br /> the originating web site only."<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 18. Track News About Yahoo!<br /><br /><br /><br /><br /><br /> Yahoo! is a big company, and there are many ways to watch Yahoo! in <br />action.<br /><br /><br /> Whether you're a potential employee, investor, competitor, or just a fan <br /> of the site, you'll want to keep tabs on what Yahoo! is doing and where it <br /> may be headed. The news sources in this hack should give you a starting <br /> point for watching the company, and you can add the RSS feeds for the <br /> sources directly to My Yahoo! or your favorite newsreader. Once you <br /> subscribe to a few Yahoo!-related feeds, you won't have any trouble <br /> keeping up with the latest news.<br /><br /><br /> 1.19.1. Yahoo! Sources<br /><br /><br /> You can use Yahoo! to find information about anything in the world, even <br /> Yahoo! itself:<br /><br /><br /><br /><br /> Yahoo! News Search<br /><br /><br /> Search over 7,000 news sources to find mentions of Yahoo! in news stories:<br /><br /><br /><br /><br /> Web<br /><br /><br /> http://search.news.yahoo.com/search/news/?p=Yahoo%21<br /><br /><br /><br /><br /> RSS<br /><br /><br /> http://news.search.yahoo.com/news/rss?ei=UTF-8&p=Yahoo%21<br /><br /><br /><br /><br /> Yahoo! Finance Search<br /><br /><br /> Track the progress of Yahoo!'s stock and find financial news and analysis <br /> at Yahoo! Finance:<br /><br /><br /><br /><br /> Stock<br /><br /><br /> http://finance.yahoo.com/q?s=YHOO<br /><br /><br /><br /><br /> News<br /><br /><br /> http://finance.yahoo.com/q/h?s=YHOO<br /><br /><br /><br /><br /> News RSS<br /><br /><br /> http://finance.yahoo.com/rss/headline?s=YHOO<br /><br /><br /><br /><br /> Yahoo! Search Blog<br /><br /><br /> This official weblog from Yahoo!, written by Yahoo! employees and special <br /> guest bloggers, gives you the inside scoop on what's new at Yahoo!:<br /><br /><br /><br /><br /> Web<br /><br /><br /> http://www.ysearchblog.com/<br /><br /><br /><br /><br /> RSS<br /><br /><br /> http://www.ysearchblog.com/index.xml<br /><br /><br /><br /><br /> Yahoo! Web Services Blog<br /><br /><br /> Find out what's happening with Yahoo! Search Web Services at this official <br /> weblog:<br /><br /><br /><br /><br /> Web<br /><br /><br /> http://developer.yahoo.net/blog<br /><br /><br /><br /><br /> RSS<br /><br /><br /> http://developer.yahoo.net/blog/index.xml<br /><br /><br /><br /><br /> Yahoo! 360 Product Blog<br /><br /><br /> The Yahoo! 360 development team keeps a weblog with the latest updates and <br /> offerings at Yahoo! 360:<br /><br /><br /><br /><br /> Web<br /><br /><br /> http://blog.360.yahoo.com/product_360<br /><br /><br /><br /><br /> RSS<br /><br /><br /> http://blog.360.yahoo.com/rss-1qCkw2Ehaak.hdNZkEAzDrpa4Q--<br /><br /><br /><br /><br /> Yahoo! Jobs<br /><br /><br /> Discover where Yahoo! is hiring with Yahoo! HotJobs:<br /><br /><br /><br /><br /> Web<br /><br /><br /> http://hotjobs.yahoo.com/jobseeker/jobsearch/search_results.html?keywords_all=Yahoo<br /><br /><br /><br /><br /> RSS<br /><br /><br /> http://hotjobs.yahoo.com/rss/0/USA/-/-/-/Yahoo<br /><br /><br /><br /><br /> Yahoo! Next<br /><br /><br /> Yahoo! promotes their latest projects at this site, and you can be sure <br /> the latest and greatest Yahoo! offerings will show up here:<br /><br /><br /><br /><br /> Web<br /><br /><br /> http://next.yahoo.com/<br /><br /><br /><br /><br /> RSS<br /><br /><br /> http://next.yahoo.com/index.rss<br /><br /><br /><br /><br /> Yahoo! Research<br /><br /><br /> Yahoo! Research is a group within Yahoo! that works on pushing the <br /> technology envelope. This site covers who they are and what they're <br /> working on:<br /><br /><br /><br /><br /> Web<br /><br /><br /> http://research.yahoo.com/<br /><br /><br /><br /><br /> Everything Yahoo!<br /><br /><br /> This page points to virtually every Yahoo! site, and it's worth visiting <br /> periodically to get a general overview of Yahoo! offerings:<br /><br /><br /><br /><br /> Web<br /><br /><br /> http://docs.yahoo.com/docs/family/more<br /><br /><br /> 1.19.2. Outside News Sources<br /><br /><br /> Not everything is available at Yahoo! Here are a few other news sources <br /> that frequently have information about Yahoo!:<br /><br /><br /><br /><br /> CNET News.blog: Yahoo<br /><br /><br /> CNET has a special weblog devoted to Yahoo!-related news:<br /><br /><br /><br /><br /> Web<br /><br /><br /> http://ecoustics-cnet.com.com/2060-65243_3-0.html<br /><br /><br /><br /><br /> RSS<br /><br /><br /> http://news.com.com/2063-65243_3-0.xml<br /><br /><br /><br /><br /> The Unofficial Yahoo! Weblog<br /><br /><br /> This is a Weblogs, Inc., production that focuses on Yahoo!:<br /><br /><br /><br /><br /> Web<br /><br /><br /> http://yahoo.weblogsinc.com/<br /><br /><br /><br /><br /> RSS<br /><br /><br /> http://yahoo.weblogsinc.com/rss.xml<br /><br /><br /><br /><br /> Wired News<br /><br /><br /> Wired News keeps tabs on the entire tech industry, and a search for Yahoo! <br /> will yield many articles:<br /><br /><br /><br /><br /> Web<br /><br /><br /> http://search.wired.com/wnews/default.asp?query=Yahoo<br /><br /><br /><br /><br /> RSS<br /><br /><br /> http://search.wired.com/wnews/default.asp?query=Yahoo&format=rss<br /><br /><br /><br /><br /> John Battelle's Searchblog<br /><br /><br /> John writes about search engines and follows Yahoo! closely:<br /><br /><br /><br /><br /> Web<br /><br /><br /> http://battellemedia.com/<br /><br /><br /><br /><br /> RSS<br /><br /><br /> http://feeds.feedburner.com/JohnBattellesSearchblog<br /><br /><br /><br /><br /> Search Engine Watch Blog<br /><br /><br /> This is a Jupitermedia weblog that follows all major search engines, <br /> including Yahoo!:<br /><br /><br /><br /><br /> Web<br /><br /><br /> http://blog.searchenginewatch.com/<br /><br /><br /><br /><br /> RSS<br /><br /><br /> http://blog.searchenginewatch.com/blog/blog.xml<br /><br /><br /><br /><br /> ResearchBuzz: Yahoo<br /><br /><br /> Tara Calishain covers all aspects of Internet research, and her Yahoo! <br /> category is continually updated:<br /><br /><br /><br /><br /> Web<br /><br /><br /> http://www.researchbuzz.org/search_enginesyahoo.shtml<br /><br /><br /><br /><br /> RSS<br /><br /><br /> http://www.researchbuzz.org/rss_search_enginesyahoo.xml<br /><br /><br /><br /><br /> Google News<br /><br /><br /> A search for Yahoo! at Google will yield news across hundreds of sources:<br /><br /><br /><br /><br /> Web<br /><br /><br /> http://news.google.com/news?q=Yahoo!<br /><br /><br /> 1.19.3. Yahoo! Employee Weblogs<br /><br /><br /> Yahoo! has over 7,600 employees, so it makes sense that some keep personal <br /> journals via weblogs. Most employee weblogs aren't connected with the <br /> company in any way, and you might not learn much about Yahoo! from them. <br /> But tune in to a few for a while and you'll definitely see the company in <br /> a new way.<br /><br /><br /><br /><br /> Yahoo! provides official blogging guidelines to their <br /> employees. You can read them at <br /> http://jeremy.zawodny.com/yahoo/yahoo-blog-guidelines.pdf.<br /><br /><br /><br /><br /><br /><br /> Here are a few employees with weblogs:<br /><br /><br /><br /><br /> Jeremy Zawodny<br /><br /><br /> Jeremy is probably the most outspoken Yahoo! employee in the blogosphere, <br /> and he frequently discusses Yahoo! on his weblog:<br /><br /><br /><br /><br /> Web<br /><br /><br /> http://jeremy.zawodny.com/blog<br /><br /><br /><br /><br /> RSS<br /><br /><br /> http://jeremy.zawodny.com/blog/rss2.xml<br /><br /><br /><br /><br /> Russell Beattie Notebook<br /><br /><br /> If you're interested in Yahoo! Mobileand mobile products in generalbe sure <br /> to tune into Russell's weblog:<br /><br /><br /><br /><br /> Web<br /><br /><br /> http://www.russellbeattie.com/notebook<br /><br /><br /><br /><br /> RSS<br /><br /><br /> http://www.russellbeattie.com/notebook/index.rss<br /><br /><br /><br /><br /> Jeffrey McManus<br /><br /><br /> Jeffery works on developer.yahoo.net, and this is his personal weblog:<br /><br /><br /><br /><br /> Web<br /><br /><br /> http://mcmanus.typepad.com/<br /><br /><br /><br /><br /> RSS<br /><br /><br /> http://mcmanus.typepad.com/grind/index.rdf<br /><br /><br /><br /><br /> Little. Yellow. Different.<br /><br /><br /> Ernie Hsiung has been writing his weblog for years, and at the time of <br /> this writing he's working on the weblog features of Yahoo! 360:<br /><br /><br /><br /><br /> Web<br /><br /><br /> http://www.littleyellowdifferent.com/<br /><br /><br /><br /><br /> RSS<br /><br /><br /> http://www.littleyellowdifferent.com/index.xml<br /><br /><br /><br /><br /> Ravi's Blog<br /><br /><br /> Ravi Donamraju is a Yahoo! Search engineer:<br /><br /><br /><br /><br /> Web<br /><br /><br /> http://www.dronamraju.com/journal/index.html<br /><br /><br /><br /><br /> RSS<br /><br /><br /> http://www.dronamraju.com/journal/rss.xml<br /><br /><br /><br /><br /> Premshree's Personal Weblog<br /><br /><br /> Premshree is a self-described hacker and is a contributor to this book:<br /><br /><br /><br /><br /> Web<br /><br /><br /> http://www.livejournal.com/users/premshree<br /><br /><br /><br /><br /> RSS<br /><br /><br /> http://feeds.feedburner.com/premshree<br /><br /><br /><br /><br /> Ian C. Roger's Y! blog<br /><br /><br /> Ian works for Yahoo! Music and writes about web technology on his Yahoo! <br /> 360 blog:<br /><br /><br /><br /><br /> Web<br /><br /><br /> http://blog.360.yahoo.com/blog-FDuiCSg4eqinB8z.GGJ7TmAz<br /><br /><br /><br /><br /> RSS<br /><br /><br /> http://blog.360.yahoo.com/rss-FDuiCSg4eqinB8z.GGJ7TmAz<br /><br /><br /> You can probably spot many more employee weblogs by browsing to Yahoo! <br /> Search (http://search.yahoo.com/) and typing in the phrase "I work at <br /> Yahoo" weblog or "I work for Yahoo" weblog.<br /><br /><br /> 1.19.4. Grassroots Sources<br /><br /><br /> Even though these sources don't pass through an editor, and the content <br /> isn't produced by professionals, these sources can provide a unique <br /> perspective on the company, point to interesting personal opinions, or <br /> refer you to obscure bits of information about Yahoo!:<br /><br /><br /><br /><br /> Flickr Photos<br /><br /><br /> Public photos tagged with Yahoo! at Flickr are often photos by employees, <br /> pictures from Yahoo! campuses, or pictures from Yahoo! events:<br /><br /><br /><br /><br /> Web<br /><br /><br /> http://www.flickr.com/photos/tags/yahoo<br /><br /><br /><br /><br /> RSS:<br /><br /><br /> http://www.flickr.com/services/feeds/photos_public.gne?tags=yahoo&format=rss_200<br /><br /><br /><br /><br /> del.icio.us<br /><br /><br /> The social bookmarks service del.icio.us has hundreds of people swapping <br /> links, and every day there are several dozen tagged with Yahoo!:<br /><br /><br /><br /><br /> Web<br /><br /><br /> http://del.icio.us/tag/yahoo<br /><br /><br /><br /><br /> RSS<br /><br /><br /> http://del.icio.us/rss/tag/yahoo<br /><br /><br /><br /><br /> Furl<br /><br /><br /> Like del.icio.us, Furl is a way to share links, and you can tune into the <br /> Yahoo! headlines:<br /><br /><br /><br /><br /> Web<br /><br /><br /> http://www.furl.net/furled.jsp?topic=yahoo<br /><br /><br /><br /><br /> RSS<br /><br /><br /> http://www.furl.net/members/rss.xml?topic=yahoo<br /><br /><br /><br /><br /> Technorati<br /><br /><br /> Use Technorati to find weblog posts that mention Yahoo!. Technorati's <br /> Yahoo! tag page also pulls in content from Flickr, del.icio.us, and Furl:<br /><br /><br /><br /><br /> Web<br /><br /><br /> http://www.technorati.com/tag/Yahoo<br /><br /><br /><br /><br /> Daypop<br /><br /><br /> Daypop is another weblog search that can point out mentions of Yahoo! <br /> across the blogosphere:<br /><br /><br /><br /><br /> Web<br /><br /><br /> http://www.daypop.com/search?q=yahoo&t=w<br /><br /><br /><br /><br /> RSS<br /><br /><br /> http://www.daypop.com/search?q=yahoo&s=1&c=10&ext=true&t=w&o=rss<br /><br /><br /><br /><br /> Yahoo!-related Yahoo! Groups<br /><br /><br /> Check out the Yahoo! category on Yahoo! Groups to see what Yahoo!-related <br /> topics people are discussing:<br /><br /><br /><br /><br /> Web<br /><br /><br /> http://dir.groups.yahoo.com/dir/1600653854<br /><br /><br /> It would be impossible to track everything Yahoo! is doing on a daily <br /> basis, but subscribing to a combination of these sources should help keep <br /> you in the Yahoo! loop.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 19. Spider the Yahoo! Catalog<br /><br /><br /><br /><br /><br /> Writing a spider to spider an existing spider's site may seem convoluted, <br /> but it can prove useful when you're looking for location-based services. <br /> This hack walks through creating a framework for full-site spidering, <br /> including additional filters to lessen your load.<br /><br /><br /> In this hack, you'll learn how to write a spider that crawls the Yahoo! <br /> group of portals. The choice of Yahoo! was obvious; because it is one of <br /> the largest Internet portals in existence, it can serve as an ideal <br /> example of how one goes about writing a portal spider.<br /><br /><br /> But before we get to the gory details of code, let's define what exactly a <br /> portal spider is. While many may argue with such a classification, I <br /> maintain that a portal spider is a script that automatically downloads all <br /> documents from a preselected range of URLs found on the portal's site or a <br /> group of sites, as is the case with Yahoo!. A portal spider's main job is <br /> to walk from one document to another, extract URLs from downloaded HTML, <br /> process said URLs, and go to another document, repeating the cycle until <br /> it runs out of URLs to visit. Once you create code that describes such <br /> basic behavior, you can add additional functionality, turning your general <br /> portal spider into a specialized one.<br /><br /><br /> Although writing a script that walks from one Yahoo! page to another <br /> sounds simple, it isn't, because there is no general pattern followed by <br /> all Yahoo! sites or sections within those sites. Furthermore, Yahoo! is <br /> not a single site with a nice link layout that can be described using a <br /> simple algorithm and a classic data structure. Instead, it is a collection <br /> of well over 30 thematic sites, each with its own document layout, naming <br /> conventions, and peculiarities in page design and URL patterns. For <br /> example, if you check links to the same directory section on different <br /> Yahoo! sites, you will find that some of them begin with <br /> http://www.yahoo.com/r, some begin with http://uk.yahoo.com/r/hp/dr, and <br /> others begin with http://kr.yahoo.com.<br /><br /><br /> If you try to look for patterns, you will soon find yourself writing long <br /> if/ elsif/else sections that are hard to maintain and need to be rewritten <br /> every time Yahoo! makes a small change to one of its sites. If you follow <br /> that route, you will soon discover that you need to write hundreds of <br /> lines of code to describe every kind of behavior you want to build into <br /> your spider.<br /><br /><br /> This is particularly frustrating to programmers who expect to write code <br /> that uses elegant algorithms and nicely structured data. The hard truth <br /> about portals is that you cannot expect elegance and ease of spidering. <br /> Instead, prepare yourself for a lot of detective work and writing (and <br /> throwing away) chunks of code in a hit-and-miss fashion. Portal spiders <br /> are written in an organic, unstructured way, and the only rule you should <br /> follow is to keep things simple and add specific functionality only once <br /> you have the general behavior working.<br /><br /><br /> Okaywith taxonomy and general advice behind us, we can get to the gist of <br /> the matter. The spider in this hack is a relatively simple tool for <br /> crawling Yahoo! sites. It makes no assumptions about the layout of the <br /> sites; in fact, it makes almost no assumptions whatsoever and can easily <br /> be adapted to other portals or even groups of portals. You can use it as a <br /> framework for writing specialized spiders.<br /><br /><br /> 1.20.1. The Code<br /><br /><br /> Save the following code to a file called yspider.pl:<br /><br /><br /> #!/usr/bin/perl -w<br /> #<br /> # yspider.pl<br /> #<br /> # Yahoo! Spider--crawls Yahoo! sites, collects links from each downloaded <br /> HTML<br /> # page, searches each downloaded page and prints a list of results when <br /> done.<br /> # http://www.artymiak.com/software/ or contact jacek@artymiak.com<br /> #<br /> # This code is free software; you can redistribute it and/or<br /> # modify it under the same terms as Perl itself.<br /> use strict;<br /> use Getopt::Std;# parse command line options.<br /> use LWP::UserAgent;# download data from the net.<br /> use HTML::LinkExtor;# get links inside an HTML document.<br /> use URI::URL;# turn relative links into absolutes.<br /><br /><br /> my $help = <<"EOH";<br /> ------------------------------------------------------------------------<br /> Yahoo! Spider.<br /><br /><br /> Options: -slist of sites you want to crawl,<br /> e.g. -s 'us china denmark'<br /> -hprint this help<br /><br /><br /> Allowed values of -s are:<br /><br /><br /> argentina, asia, australia, brazil, canada,<br /> catalan, china, denmark, france, germany, hongkong,<br /> india, ireland, italy, japan, korea, mexico,<br /> newzealand, norway, singapore, spain, sweden, taiwan,<br /> uk, us, us_chinese, us_spanish<br /> Please, use this code responsibly. Flooding any site<br /> with excessive queries is bad net citizenship.<br /> ------------------------------------------------------------------------<br /> EOH<br /><br /><br /> # define our arguments and<br /> # show the help if asked.<br /> my %args; getopts("s:h", \%args);<br /> die $help if exists $args{h};<br /><br /><br /> # The list of code names, and<br /> # URLs, for various Yahoo! sites.<br /> my %ys = (<br /> argentina => "http://ar.yahoo.com", asia => "http://asia.yahoo.com",<br /> australia => "http://au.yahoo.com", newzealand => "http://au.yahoo.com",<br /> brazil => "http://br.yahoo.com", canada => "http://ca.yahoo.com",<br /> catalan => "http://ct.yahoo.com", china => "http://cn.yahoo.com",<br /> denmark => "http://dk.yahoo.com", france => "http://fr.yahoo.com",<br /> germany => "http://de.yahoo.com", hongkong => "http://hk.yahoo.com",<br /> india => "http://in.yahoo.com", italy => "http://it.yahoo.com",<br /> korea => "http://kr.yahoo.com", mexico => "http://mx.yahoo.com",<br /> norway => "http://no.yahoo.com", singapore => "http://sg.yahoo.com",<br /> spain => "http://es.yahoo.com", sweden => "http://se.yahoo.com",<br /> taiwan => "http://tw.yahoo.com", uk => "http://uk.yahoo.com",<br /> ireland => "http://uk.yahoo.com", us => "http://www.yahoo.com",<br /> japan => "http://www.yahoo.co.jp",<br /> us_chinese => "http://chinese.yahoo.com",<br /> us_spanish => "http://espanol.yahoo.com"<br /> );<br /><br /><br /> # if the -s option was used, check to make<br /> # sure it matches one of our existing codes<br /> # above. if not, or no -s was passed, help.<br /> my @sites; # which locales to spider.<br /> if (exists $args{'s'}) {<br /> @sites = split(/ /, lc($args{'s'}));<br /> foreach my $site (@sites) {<br /> die "UNKNOWN: $site\n\n$help" unless $ys{$site};<br /> }<br /> } else { die $help; }<br /><br /><br /> # Defines global and local profiles for URLs extracted from the<br /> # downloaded pages. These profiles are used to determine if the<br /> # URLs extracted from each new document should be placed on the<br /> # TODO list (%todo) or rejected (%rejects). Profiles are lists<br /> # made of chunks of text, which are matched against found URLs.<br /> # Any special characters, like slash (/) or dot (.) must be properly<br /> # escaped. Remember that globals have precedence over locals.<br /> my %rules = (<br /> global => { allow => [], deny => [ 'search', '\*' ] },<br /> argentina => { allow => [ 'http:\/\/ar\.' ], deny => [] },<br /> asia => { allow => [ 'http:\/\/(aa|asia)\.' ], deny => [] },<br /> australia => { allow => [ 'http:\/\/au\.' ], deny => [] },<br /> brazil => { allow => [ 'http:\/\/br\.' ], deny => [] },<br /> canada => { allow => [ 'http:\/\/ca\.' ], deny => [] },<br /> catalan => { allow => [ 'http:\/\/ct\.' ], deny => [] },<br /> china => { allow => [ 'http:\/\/cn\.' ], deny => [] },<br /> denmark => { allow => [ 'http:\/\/dk\.' ], deny => [] },<br /> france => { allow => [ 'http:\/\/fr\.' ], deny => [] },<br /> germany => { allow => [ 'http:\/\/de\.' ], deny => [] },<br /> hongkong => { allow => [ 'http:\/\/hk\.' ], deny => [] },<br /> india => { allow => [ 'http:\/\/in\.' ], deny => [] },<br /> ireland => { allow => [ 'http:\/\/uk\.' ], deny => [] },<br /> italy => { allow => [ 'http:\/\/it\.' ], deny => [] },<br /> japan => { allow => [ 'yahoo\.co\.jp' ], deny => [] },<br /> korea => { allow => [ 'http:\/\/kr\.' ], deny => [] },<br /> mexico => { allow => [ 'http:\/\/mx\.' ], deny => [] },<br /> norway => { allow => [ 'http:\/\/no\.' ], deny => [] },<br /> singapore => { allow => [ 'http:\/\/sg\.' ], deny => [] },<br /> spain => { allow => [ 'http:\/\/es\.' ], deny => [] },<br /> sweden => { allow => [ 'http:\/\/se\.' ], deny => [] },<br /> taiwan => { allow => [ 'http:\/\/tw\.' ], deny => [] },<br /> uk => { allow => [ 'http:\/\/uk\.' ], deny => [] },<br /> us => { allow => [ 'http:\/\/(dir|www)\.' ], deny => [] },<br /> us_chinese => { allow => [ 'http:\/\/chinese\.' ], deny => [] },<br /> us_spanish => { allow => [ 'http:\/\/espanol\.' ], deny => [] },<br /> );<br /> my %todo = ( ); # URLs to parse<br /> my %done = ( ); # parsed/finished URLs<br /> my %errors = ( ); # broken URLs with errors.<br /> my %rejects = ( ); # URLs rejected by the script<br /><br /><br /> # print out a "we're off!" line, then<br /> # begin walking the site we've been told to.<br /> print "=" x 80 . "\nStarted Yahoo! spider…\n" . "=" x 80 . "\n";<br /> our $site; foreach $site (@sites) {<br /><br /><br /> # for each of the sites that have been passed on the<br /> # command line, we make a title for them, add them to<br /> # the TODO list for downloading, then call walksite( ),<br /> # which downloads the URL, looks for more URLs, etc.<br /> my $title = "Yahoo! " . ucfirst($site) . " front page";<br /> $todo{$ys{$site}} = $title; walksite( ); # process.<br /> }<br /><br /><br /> # once we're all done with all the URLs, we print a<br /> # report about all the information we've gone through.<br /> print "=" x 80 . "\nURLs downloaded and parsed:\n" . "=" x 80 . "\n";<br /> foreach my $url (keys %done) { print "$url => $done{$url}\n"; }<br /> print "=" x 80 . "\nURLs that couldn't be downloaded:\n" . "=" x 80 . <br />"\n";<br /> foreach my $url (keys %errors) { print "$url => $errors{$url}\n"; }<br /> print "=" x 80 . "\nURLs that got rejected:\n" . "=" x 80 . "\n";<br /> foreach my $url (keys %rejects) { print "$url => $rejects{$url}\n"; }<br /><br /><br /> # this routine grabs the first entry in our todo<br /> # list, downloads the content, and looks for more URLs.<br /> # we stay in walksite until there are no more URLs<br /> # in our to do list, which could be a good long time.<br /> sub walksite {<br /><br /><br /> do {<br /> # get first URL to do.<br /> my $url = (keys %todo)[0];<br /><br /><br /> # download this URL<br /> print "-> trying $url…\n";<br /> my $browser = LWP::UserAgent->new;<br /> my $resp = $browser->get( $url, 'User-Agent' => 'Y!SpiderHack/1.0' );<br /><br /><br /> # check the results.<br /> if ($resp->is_success) {<br /> my $base = $resp->base || '';<br /> print "-> base URL: $base\n";<br /> my $data = $resp->content; # get the data.<br /> print "-> downloaded: " . length($data) . " bytes of $url\n";<br /><br /><br /> # find URLs using a link extorter. relevant ones<br /> # will be added to our to do list of downloadables.<br /> # this passes all the found links to findurls( )<br /> # below, which determines if we should add the link<br /> # to our to do list, or ignore it due to filtering.<br /> HTML::LinkExtor->new(\&findurls, $base)->parse($data);<br /><br /><br /> ###########################################################<br /> # add your own processing here. perhaps you'd like to add #<br /> # a keyword search for the downloaded content in $data? #<br /> ###########################################################<br /><br /><br /> } else {<br /> $errors{$url} = $resp->message( );<br /> print "-> error: couldn't download URL: $url\n";<br /> delete $todo{$url};<br /> }<br /><br /><br /> # we're finished with this URL, so move it from<br /> # the to do list to the done list, and print a report.<br /> $done{$url} = $todo{$url}; delete $todo{$url};<br /> print "-> processed legal URLs: " . (scalar keys %done) . "\n";<br /> print "-> remaining URLs: " . (scalar keys %todo) . "\n";<br /> print "-" x 80 . "\n";<br /> } until ((scalar keys %todo) == 0);<br /> }<br /><br /><br /> # callback routine for HTML::LinkExtor. For every<br /> # link we find in our downloaded content, we check<br /> # to see if we've processed it before, then run it<br /> # through a bevy of regexp rules (see the top of<br /> # this script) to see if it belongs in the to do.<br /> sub findurls {<br /> my($tag, %links) = @_;<br /> return if $tag ne 'a';<br /> return unless $links{href};<br /> print "-> found URL: $links{href}\n";<br /><br /><br /> # already seen this URL, so move on.<br /> if (exists $done{$links{href}} ||<br /> exists $errors{$links{href}} ||<br /> exists $rejects{$links{href}}) {<br /> print "--> I've seen this before: $links{href}\n"; return;<br /> }<br /><br /><br /> # now, run through our filters.<br /> unless (exists($todo{$links{href}})) {<br /> my ($ga, $gd, $la, $ld); # counters.<br /> foreach (@{$rules{global}{'allow'}}) { $ga++ if $links{href} =~<br /><br /><br /><br /> /$_/i; }<br /> foreach (@{$rules{global}{'deny'}}) { $gd++ if $links{href} =~<br /><br /><br /><br /><br /><br /> /$_/i; }<br /> foreach (@{$rules{$site}{'allow'}}) { $la++ if $links{href} =~ <br /><br /><br /><br /> /$_/i; }<br /> foreach (@{$rules{$site}{'deny'}}) { $ld++ if $links{href} =~ /$_/i; }<br /><br /><br /> # if there were denials or NO allowances, we move on.<br /> if ($gd or $ld) { print "-> rejected URL: $links{href}\n"; return; }<br /> unless ($ga or $la) { print "-> rejected URL: $links{href}\n"; <br /><br /><br /><br /> return; }<br /> # we passed our filters, so add it on the barby.<br /> print "-> added $links{href} to my TODO list\n";<br /> $todo{$links{href}} = $links{href};<br /> }<br /> }<br /><br /><br /><br /><br /> 1.20.2. Running the Hack<br /><br /><br /> Before sending the spider off, you'll need to make a decision regarding <br /> which part of the Yahoo! directory you want to crawl. If you're mainly <br /> interested in the United States and United Kingdom, inform the spider of <br /> that by using the -s option on the command line, like so:<br /><br /><br /> % perl yspider.pl -s "us uk"<br /> =================================================================<br /> Started Yahoo! spider…<br /> =================================================================<br /> -> trying http://www.yahoo.com…<br /> -> base URL: http://www.yahoo.com/<br /> -> downloaded: 28376 bytes of http://www.yahoo.com<br /> -> found URL: http://www.yahoo.com/s/92802<br /> -> added http://www.yahoo.com/s/92802 to my TODO list<br /> -> found URL: http://www.yahoo.com/s/92803<br /> …etc…<br /> -> added http://www.yahoo.com/r/pv to my TODO list<br /> -> processed legal URLs: 1<br /> -> remaining URLs: 244<br /><br /><br /> -> trying http://www.yahoo.com/r/fr…<br /> -> base URL: http://fr.yahoo.com/r/<br /> -> downloaded: 32619 bytes of http://www.yahoo.com/r/fr<br /> -> found URL: http://fr.yahoo.com/r/t/mu00<br /> -> rejected URL: http://fr.yahoo.com/r/t/mu00<br /> …<br /><br /><br /><br /><br /> You can see a full list of locations available to you by asking for help:<br /><br /><br /> % perl yspider.plh<br /> …<br /> Allowed values of -s are:<br /><br /><br /> argentina, asia, australia, brazil, canada, catalan, china, <br /> denmark, france, germany, hongkong, india, ireland, italy, japan, korea, <br /> mexico, newzealand, norway, singapore, spain, sweden, <br /> taiwan, uk, us, us_chinese, us_spanish<br /><br /><br /><br /><br /> 1.20.3. Hacking the Hack<br /><br /><br /> The section you'll want to modify most contains the filters that determine <br /> how far the spider will go; by tweaking the allow and deny rules at the <br /> beginning of the script, you'll be able to better grab just the content <br /> you're interested in. If you want to make this spider even more generic, <br /> consider rewriting the configuration code so that it'll instead read a <br /> plain-text list of code names, start URLs, and allow and deny patterns. <br /> This can turn a Yahoo! spider into a general Internet spider.<br /><br /><br /> Whenever you want to add code that extends the functionality of this <br /> spider (such as searching for keywords in a document, adding the <br /> downloaded content to a database, or otherwise repurposing it for your <br /> needs), include your own logic where specified by the hashed-out comment <br /> block.<br /><br /><br /> 1.20.4. See Also<br /><br /><br /><br /> If you're spidering Yahoo! because you want to start your own directory, <br /> you might want to consider Google's Open Directory Project <br /> (http://dmoz.org/about.html). Downloading the project's freely available <br /> directory data, all several hundred megs of it, will give you plenty of <br /> information to play with. <br /><br /><br /> Jacek Artymiak<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 20. Browse the Yahoo! Directory<br /><br /><br /><br /><br /><br /> When you don't know exactly what you're looking for, the Yahoo! Directory <br /> might be able to help you find it.<br /><br /><br /> Yahoo! started in 1994 as Jerry Yang and David Filo's organized list of <br /> favorite sites they'd found on the Web. Yahoo! has grown into much, much <br /> more, and many people think of Yahoo! as strictly a search company. <br /> Searching is great when you have a fairly good idea of what you're looking <br /> for, but the Yahoo! Directory is a great place when you'd rather browse.<br /><br /><br /> 1.21.1. Searching Versus Browsing<br /><br /><br /> There are two different kinds of shoppers, and they illustrate the <br /> difference between searching and browsing. Some shoppers know exactly what <br /> they're after and they want to find a store that carries that item, locate <br /> it in the store, and purchase it as quickly as possible. As with a web <br /> search, it helps to know a bit about what you're looking for if this is <br /> your style. Other shoppers want to explore a particular store, see what <br /> the store offers, and choose an item if the right one comes along. This <br /> style of browsing is suited to people who want to get a larger survey of <br /> items in a particular category before they necessarily decide what they're <br /> looking for.<br /><br /><br /> Search forms are obviously built for searching. Directories are built for <br /> browsing. Unlike Yahoo! Search results, the Yahoo! Directory doesn't try <br /> to include every page it can find from across the Web. Instead, the sites <br /> listed in the directory are hand picked and reviewed by paid Yahoo! <br /> editors.<br /><br /><br /> If you were interested in looking at a sampling of weblogs about politics, <br /> you might try a search at http://search.yahoo.com/ with the query <br /> political weblog. You would find political weblogs in the search results, <br /> along with news articles about political weblogs, college papers about <br /> political weblogs, and even pages that just mention the terms political <br /> and weblogs. But browsing the Political Weblogs category in the Yahoo! <br /> Directory <br /> (http://dir.yahoo.com/Computers_and_Internet/Internet/World_Wide_Web/Weblogs/Politics) <br /> will give you hundreds of links that have been selected by Yahoo! <br /> employees as being political weblogs.<br /><br /><br /><br /><br /> The editors leave it as an exercise to the reader to determine <br /> which side of the political spectrum any given weblog is on.<br /><br /><br /><br /><br /><br /><br /> In addition to a less noisy list of sites to browse, you'll find other <br /> evidence of the editors in the directory. Some sites will have a PICK! <br /> icon after them, along with a review of the site, like the last entry <br /> shown in Figure 1-51.<br /><br /><br /><br /><br /> Figure 1-51. The Slang Dictionaries category in the Yahoo! Directory<br /><br /><br /><br /><br /><br /> Click the "read review" link after any PICK! icon to see a brief <br /> description of the site, written by a Yahoo! editor. Other sites that have <br /> been chosen as cool by Yahoo! editors have an icon of sunglasses next to <br /> their listing.<br /><br /><br /><br /><br /> If you spot a site in the directory that you'd like to see <br /> chosen and reviewed as a Yahoo! pick, you can email your <br /> suggestion to suggest-picks@yahoo-inc.com. You can read new <br /> picks at http://picks.yahoo.com/.<br /><br /><br /><br /><br /><br /><br /> 1.21.2. Adding a Site<br /><br /><br /> Unlike the Yahoo! Search index, which is constantly looking for and adding <br /> new sites automatically, the Yahoo! Directory considers sites for <br /> inclusion only from user suggestions. You can suggest a site for the <br /> Yahoo! Directory by browsing to the category you'd like to see the site <br /> listed in and clicking the "Suggest a Site" link at the top of the page. <br /> From there, you'll be asked to choose a paid or free listing (paying users <br /> get preferential treatment, including faster listing times). If you choose <br /> the free option, you'll be asked to confirm the category and enter the <br /> site information.<br /><br /><br /> Because there are hundreds of requests, it's not possible for Yahoo! to <br /> include all of the suggested sites. But if you've found that your site <br /> isn't included within a few weeks of submitting it, you can submit your <br /> site again.<br /><br /><br /><br /><br /> Multiple submissions in a short period are considered abuse by <br /> Yahoo! and the request won't be considered.<br /><br /><br /><br /><br /><br /><br /> If your site is accepted, it will appear at the top of the list with a <br /> NEW! icon next to it for two weeks. The Yahoo! for Webmasters chapter has <br /> even more details about adding a site to Yahoo! [Hack #92].<br /><br /><br /> Keeping up with recent additions to categories you're interested in is a <br /> great way to find new sites. You can subscribe to new additions in a <br /> particular category via RSS, or add the category's feed to your list of My <br /> Yahoo! news sources. To get started, browse to the Yahoo! Directory RSS <br /> Feeds page at http://dir.yahoo.com/rss/dir/index.php and choose from the <br /> categories listed.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 21. Track Additions to Yahoo!<br /><br /><br /><br /><br /><br /> Keep track of the number of sites added to your favorite Yahoo! <br />categories.<br /><br /><br /> Every day, a squad of surfers at Yahoo! adds new sites to the Yahoo! <br /> index. These changes are reflected in the Yahoo! What's New page <br /> (http://dir.yahoo.com/new), along with the Picks of the Day.<br /><br /><br /> If you're a casual surfer, you might not care about the number of new <br /> sites added to Yahoo!. But there are several scenarios when you might have <br /> an interest:<br /><br /><br /><br /><br /> You regularly glean information about new sites from Yahoo!<br /><br /><br /> Knowing which categories are growing and which categories are stagnant <br /> will tell you where to direct your attention.<br /><br /><br /><br /><br /> You want to submit sites to Yahoo!<br /><br /><br /> Are you going to spend your hard-earned money adding a site to a category <br /> where new sites are added constantly (meaning your submitted site might <br /> quickly get buried)? Or will you be paying to add to a category that sees <br /> few additions (meaning your site might have a better chance of standing <br /> out)?<br /><br /><br /><br /><br /> You're interested in trend tracking<br /><br /><br /> Which categories are consistently busy? Which are all but dead? By <br /> watching how Yahoo! adds sites to categories, over time you'll get a sense <br /> of the rhythms and trends and detect when unusual activity occurs in a <br /> category.<br /><br /><br /> This hack scrapes the recent counts of additions to Yahoo! categories and <br /> prints them out, providing an at-a-glance look at additions to various <br /> categories. You'll also get a tab-delimited table of how many sites have <br /> been added to each category for each day. A tab-delimited file is <br /> excellent for importing into a spreadsheet, where you can turn the count <br /> numbers into a chart.<br /><br /><br /> 1.22.1. The Code<br /><br /><br /> Save the following code to a file called hoocount.pl:<br /><br /><br /> #!/usr/bin/perl -w<br /><br /><br /> use strict;<br /> use Date::Manip;<br /> use LWP::Simple;<br /> use Getopt::Long;<br /><br /><br /> $ENV{TZ} = "GMT" if $^O eq "MSWin32";<br /><br /><br /> # the homepage for Yahoo!'s "What's New".<br /> my $new_url = "http://dir.yahoo.com/new/";<br /><br /><br /> # the major categories at Yahoo!. hash'd because<br /> # we'll use them to hold our counts string.<br /> my @categories = ("Arts & Humanities","Business & Economy",<br /> "Computers & Internet","Education",<br /> "Entertainment","Government",<br /> "Health","News & Media",<br /> "Recreation & Sports","Reference",<br /> "Regional","Science",<br /> "Social Science","Society & Culture");<br /> my %final_counts; # where we save our final readouts.<br /><br /><br /> # load in our options from the command line.<br /> my %opts; GetOptions(\%opts, "c|count=i");<br /> die unless $opts{c}; # count sites from past $i days.<br /><br /><br /> # if we've been told to count the number of new sites,<br /> # then we'll go through each of our main categories<br /> # for the last $i days and collate a result.<br /><br /><br /> # begin the header<br /> # for our import file.<br /> my $header = "Category";<br /><br /><br /> # from today, going backwards, get $i days.<br /> for (my $i=1; $i <= $opts{c}; $i++) {<br /><br /><br /> # create a Data::Manip time that will<br /> # be used to construct the last $i days<br /> my $day; # query for Yahoo! retrieval.<br /> if ($i == 1) { $day = "yesterday"; }<br /> else { $day = "$i days ago"; }<br /> my $date = UnixDate($day, "%Y%m%d");<br /><br /><br /> # and this date to<br /> # our import file.<br /> $header .= "\t$date";<br /><br /><br /> # and download the day.<br /> my $url = "$new_url$date.html";<br /> my $data = get($url) or die $!;<br /><br /><br /> # and loop through each of our categories.<br /> my $day_count; foreach my $category (sort @categories) {<br /> $data =~ /$category.*?(\d+)/; my $count = $1 || 0;<br /> $final_counts{$category} .= "\t$count"; # building our string.<br /> }<br /> }<br /><br /><br /> # with all our counts finished,<br /> # print out our final file.<br /> print $header . "\n";<br /> foreach my $category (@categories) {<br /> print $category, $final_counts{$category}, "\n";<br /> }<br /><br /><br /><br /><br /> 1.22.2. Running the Hack<br /><br /><br /> The only argument you need to provide to the script is the number of days <br /> back you'd like it to travel in search of new additions. Since Yahoo! <br /> doesn't archive its "new pages added" indefinitely, a safe upper limit is <br /> around two weeks. Here, we're looking at the past two days:<br /><br /><br /> % perl hoocount.pl --count 2<br /> Category2005071120050710<br /> Arts & Humanities329<br /> Business & Economy442<br /> Computers & Internet300<br /> Education00<br /> Entertainment770<br /> Government20<br /> Health110<br /> News & Media00<br /> Recreation & Sports481<br /> Reference00<br /> Regional813<br /> Science 69<br /> Social Science00<br /> Society & Culture120<br /><br /><br /><br /><br /> 1.22.3. Hacking the Hack<br /><br /><br /> If you're not only a researcher but also a Yahoo! observer, you might be <br /> interested in how the number of sites added changes over time. To that <br /> end, you could run this script under cron or the Windows Scheduler and <br /> output the results to a file. After three months or so, you'd have a <br /> pretty interesting set of counts to manipulate with a spreadsheet program.<br /><br /><br /> Kevin Hemenway and Tara Calishain<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 22. Yahoo! Directory Mindshare in Google<br /><br /><br /><br /><br /><br /> How does link popularity compare in Yahoo!'s searchable subject index <br /> versus Google's full-text index? Find out by calculating mindshare!<br /><br /><br /> Yahoo! and Google are two very different animals. Yahoo! indexes only a <br /> site's main URL, title, and description, while Google builds full-text <br /> indexes of entire sites. Surely there's some interesting cross-pollination <br /> when you combine results from the two.<br /><br /><br /> This hack scrapes all the URLs in a specified subcategory of the Yahoo! <br /> directory. It then takes each URL and gets its link count from Google. <br /> Each link count provides a nice snapshot of how a particular Yahoo! <br /> category and its listed sites stack up on the popularity scale.<br /><br /><br /><br /><br /> What's a link count? It's simply the total number of pages in <br /> Google's index that link to a specific URL.<br /><br /><br /><br /><br /><br /><br /> There are a couple of ways you can use your knowledge of a subcategory's <br /> link count. If you find a subcategory whose URLs have only a few links <br /> each in Google, you may have found a subcategory that isn't getting a lot <br /> of attention from Yahoo!'s editors. Consider going elsewhere for your <br /> research. If you're a webmaster and you're considering paying to have <br /> Yahoo! add you to its directory, run this hack on the category in which <br /> you want to be listed. Are most of the links really popular? If they are, <br /> are you sure your site will stand out and get clicks? Maybe you should <br /> choose a different category.<br /><br /><br /> We got this idea from a similar experiment done by Jon Udell <br /> (http://weblog.infoworld.com/udell) in 2001. He used AltaVista instead of <br /> Google; see http://udell.roninhouse.com/download/mindshare-script.txt. We <br /> appreciate the inspiration, Jon!<br /><br /><br /> 1.23.1. The Code<br /><br /><br /> You will need a Google API account (http://api.google.com/) as well as the <br /> Perl modules SOAP::Lite (http://www.soaplite.com/) and HTML::LinkExtor <br /> (http://search.cpan.org/author/GAAS/HTML-Parser/lib/HTML/LinkExtor.pm) to <br /> run the following code. You'll also need a copy of the Google WSDL file in <br /> the same directory as the script <br /> (http://api.google.com/GoogleSearch.wsdl). Save the following code to a <br /> file called mindshare.pl:<br /><br /><br /> #!/usr/bin/perl -w<br /><br /><br /> use strict;<br /> use LWP::Simple;<br /> use HTML::LinkExtor;<br /> use SOAP::Lite;<br /><br /><br /> my $google_key = "your API key goes here";<br /> my $google_wdsl = "GoogleSearch.wsdl";<br /> my $yahoo_dir = shift || "/Computers_and_Internet/Data_Formats/XML_ _".<br /> "eXtensible_Markup_Language_/RSS/Aggregators/";<br /><br /><br /> # download the Yahoo! directory.<br /> my $data = get("http://dir.yahoo.com" . $yahoo_dir) or die $!;<br /><br /><br /> # create our Google object.<br /> my $google_search = SOAP::Lite->service("file:$google_wdsl");<br /> my %urls; # where we keep our counts and titles.<br /> # extract all the links and parse 'em.<br /> HTML::LinkExtor->new(\&mindshare)->parse($data);<br /> sub mindshare { # for each link we find…<br /><br /><br /> my ($tag, %attr) = @_;<br /><br /><br /> # only continue on if the tag was a link,<br /> # and the URL matches Yahoo!'s redirectory,<br /> return if $tag ne 'a';<br /> return if $attr{href} =~ /us.rd.yahoo/;<br /> return unless $attr{href} =~ /^http/;<br /><br /><br /> # and process each URL through Google.<br /> my $results = $google_search->doGoogleSearch(<br /> $google_key, "link:$attr{href}", 0, 1,<br /> "true", "", "false", "", "", ""<br /> ); # wheee, that was easy, guvner.<br /> $urls{$attr{href}} = $results->{estimatedTotalResultsCount};<br /> }<br /><br /><br /> # now sort and display.<br /> my @sorted_urls = sort { $urls{$b} <=> $urls{$a} } keys %urls;<br /> foreach my $url (@sorted_urls) { print "$urls{$url}: $url\n"; }<br /><br /><br /><br /><br /> 1.23.2. Running the Hack<br /><br /><br /> The hack has its only configurationthe Yahoo! directory you're interested <br /> inpassed as a single argument (in quotes) on the command line (if you <br /> don't pass one of your own, a default directory will be used instead):<br /><br /><br /> % perl mindshare.pl "/Entertainment/Humor/Procrastination/"<br /><br /><br /><br /><br /> Your results show the URLs in those directories, sorted by total Google <br /> links:<br /><br /><br /> 554: http://www.p45.net/<br /> 339: http://www.ishouldbeworking.com/<br /> 124: http://www.india.com/<br /> 45: http://www.geocities.com/SouthBeach/1915/<br /> 15: http://www.eskimo.com/~spban/creed.html<br /> 15: http://www.jlc.net/~useless/<br /> 5: http://www.black-schaffer.org/scp/<br /> 2: http://www.angelfire.com/mi/psociety<br /> 1: http://www.geocities.com/wastingstatetime/<br /><br /><br /><br /><br /> 1.23.3. Hacking the Hack<br /><br /><br /> Yahoo! isn't the only searchable subject index out there, of course; <br /> there's also the Open Directory Project (DMOZ, http://www.dmoz.org/), <br /> which is the product of thousands of volunteers busily cataloging and <br /> categorizing sites on the Webthe web community's Yahoo!, if you will. This <br /> hack works just as well on DMOZ as it does on Yahoo!; they're very similar <br /> in structure.<br /><br /><br /> Replace the default Yahoo! directory with its DMOZ equivalent:<br /><br /><br /> my $dmoz_dir = shift || "/Reference/Libraries/Library_and_Information_<br /><br /><br /><br /> Science/".<br /> "Technical_Services/Cataloguing/Metadata/RDF/".<br /> "Applications/RSS/News_Readers/";<br /><br /><br /><br /><br /> You'll also need to change the download instructions:<br /><br /><br /> # download the Dmoz.org! directory.<br /> my $data = get("http://dmoz.org" . $dmoz_dir) or die $!;<br /><br /><br /><br /><br /> Next, replace the lines that check whether a URL should be measured for <br /> mindshare. When we were scraping Yahoo! in our original script, we skipped <br /> over Yahoo! links and those that weren't web sites:<br /><br /><br /> return if $attr{href} =~ /us.rd.yahoo/;<br /> return unless $attr{href} =~ /^http/;<br /><br /><br /><br /><br /> Since DMOZ is an entirely different site, we'll make sure it's a <br /> full-blooded location (i.e., it starts with http//:) as before and that it <br /> doesn't match any of DMOZ's internal page links. Likewise, we'll ignore <br /> searches on other engines:<br /><br /><br /> return unless $attr{href} =~ /^http/;<br /> return if $attr{href} =~ /dmoz|google|altavista|lycos|yahoo|alltheweb/;<br /><br /><br /><br /><br /> Can you go even further with this? Sure! You might want to search a more <br /> specialized directory, such as the FishHoo! fishing search engine <br /> (http://www.fishhoo.com/).<br /><br /><br /> You might want to return only the most linked-to URL from the directory, <br /> which is quite easy by piping the results to head, another common Unix <br /> utility:<br /><br /><br /> % perl mindshare.pl | head 1<br /><br /><br /><br /><br /> Alternatively, you might want to go ahead and grab the top 10 Google <br /> matches for the URL that has the most mindshare. To do so, add the <br /> following code to the bottom of the script:<br /><br /><br /> print "\nMost popular URLs for the strongest mindshare:\n";<br /> my $most_popular = shift @sorted_urls;<br /> my $results = $google_search->doGoogleSearch(<br /> $google_key, "$most_popular", 0, 10,<br /> "true", "", "false", "", "", "" );<br /><br /><br /> foreach my $element (@{$results->{resultElements}}) {<br /> next if $element->{URL} eq $most_popular;<br /> print " * $element->{URL}\n";<br /> print " \"$element->{title}\"\n\n";<br /> }<br /><br /><br /><br /><br /> Then run the script as usual (the output here uses the default hardcoded <br /> directory):<br /><br /><br /> % perl mindshare.pl<br /> 24600: http://www.newsburst.com/<br /> 22700: http://www.bloglines.com/<br /> 9640: http://radio.userland.com/<br /> 6890: http://www.feedreader.com/<br /> 4770: http://www.sharpreader.net/<br /> 4660: http://www.newsgator.com/<br /> 3580: http://www.newsisfree.com/<br /> 2680: http://www.pubsub.com/<br /> 2090: http://www.disobey.com/amphetadesk/<br /> 1740: http://www.serence.com/site.php?page=prod_klipfolio<br /> 1690: http://www.pluck.com/<br /> 1610: http://www.rssbandit.org/<br /> 1160: http://www.allheadlinenews.com/<br /> 1140: http://www.newzcrawler.com/<br /> 961: http://www.rojo.com/<br /><br /><br /> …<br /><br /><br /> Most popular URLs for the strongest mindshare:<br /> * http://www.newsburst.com/Source/?add=PUTyourFEEDurlHERE<br /> ""<br /><br /><br /> * http://deeplinking.net/xmlsrv/rss.php?blog=4<br /> "Deeplinking"<br /><br /><br /> * http://www.bloglines.com/citations?url=http://www.newsburst.com<br /> "Bloglines | Citations"<br /><br /><br /> * http://www.feedforall.com/forum/posting.php?mode=quote&p=624<br /> "FeedForAll :: Post a reply"<br /><br /><br /> …<br /><br /><br /><br /><br /> Kevin Hemenway and Tara Calishain<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Chapter 2. Services<br /><br /><br /><br /> Section 2.1. Hacks 2350: Introduction <br /><br /><br /> Hack 23. Track Your Investments <br /><br /><br /> Hack 24. Build Your Own Stock Update Email <br /><br /><br /> Hack 25. Download Financial Data Using Excel Web Queries <br /><br /><br /> Hack 26. Convert Currencies with One Click <br /><br /><br /> Hack 27. Do the Math with Yahoo! Calculators <br /><br /><br /> Hack 28. Add a Yahoo! Bookmark with One Click <br /><br /><br /> Hack 29. Import Existing Bookmarks into Yahoo! Bookmarks <br /><br /><br /> Hack 30. Open Yahoo! Bookmarks in a Sidebar <br /><br /><br /> Hack 31. Publish Your Yahoo! Bookmarks <br /><br /><br /> Hack 32. Track the Media's Attention Span over Time <br /><br /><br /> Hack 33. Monitor the News with RSS <br /><br /><br /> Hack 34. Personalize My Yahoo! <br /><br /><br /> Hack 35. Track Your Favorite Sites with RSS <br /><br /><br /> Hack 36. Add a Feed to My Yahoo! with a Right-Click <br /><br /><br /> Hack 37. Build Your Own News Crawler <br /><br /><br /> Hack 38. Replace Your Phone Book with Yahoo! <br /><br /><br /> Hack 39. Monitor Your Commute <br /><br /><br /> Hack 40. Get the Facts at Yahoo! Reference <br /><br /><br /> Hack 41. Find and Rate Movies <br /><br /><br /> Hack 42. Subscribe to Movie Showtimes <br /><br /><br /> Hack 43. View Movie Lists on Your Cell Phone <br /><br /><br /> Hack 44. Plan Your TV Viewing <br /><br /><br /> Hack 45. Create a TV Watch List <br /><br /><br /> Hack 46. Develop and Share a Trip Itinerary <br /><br /><br /> Hack 47. Shop Intelligently <br /><br /><br /> Hack 48. Visualize Your Music Collection <br /><br /><br /> Hack 49. Take Yahoo! on the Go <br /><br /><br /> Hack 50. Stay Connected with Yahoo! Alerts <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> 2.1. Hacks 2350: Introduction<br /><br /><br /> In addition to pointing people to documents and resources across the Web <br /> through Yahoo! Search and the Yahoo! Directory, Yahoo! has become a <br /> destination itself. By gathering information from many sources under a <br /> single roof, Yahoo! has made following the financial markets [Hack #23], <br /> the daily news [Hack #33], or even the products available online [Hack <br /> #47] a breeze.<br /><br /><br /> Yahoo! also allows you to personalize the information you find at the <br /> sites so the information is more meaningful to you. This means you can <br /> gather and track your favorite news sources together at My Yahoo! [Hack <br /> #34] or even visualize your personal music collection [Hack #48] in a new <br /> way. And once your personal preferences are stored at Yahoo!, they're <br /> accessible from any computer connected to the Internet. This is especially <br /> useful for storing bookmarks [Hack #28] or keeping tabs on movies you'd <br /> like to see [Hack #43].<br /><br /><br /> Yahoo! also has several methods of routing your personalized information <br /> to you when and where you need it. Yahoo! Alerts [Hack #50] can send <br /> updated information to you via email, instant messenger, or cell phone. <br /> And Yahoo! Mobile [Hack #49] can give you access to your settings on a <br /> mobile device when you're out and about.<br /><br /><br /> The hacks in this chapter are about personalizing and working with the <br /> data you'll find across Yahoo! properties. The hacks here represent only a <br /> portion of Yahoo! Here are some additional Yahoo! properties that didn't <br /> make it into the book:<br /><br /><br /><br /><br /> Ask Yahoo!<br /><br /><br /> http://ask.yahoo.com/<br /><br /><br /><br /><br /> Banking<br /><br /><br /> http://banking.yahoo.com/<br /><br /><br /><br /><br /> Cars<br /><br /><br /> http://autos.yahoo.com/<br /><br /><br /><br /><br /> Classifieds<br /><br /><br /> http://classifieds.yahoo.com/<br /><br /><br /><br /><br /> Health<br /><br /><br /> http://health.yahoo.com/<br /><br /><br /><br /><br /> Horoscopes<br /><br /><br /> http://astrology.yahoo.com/<br /><br /><br /><br /><br /> Insurance<br /><br /><br /> http://insurance.yahoo.com/<br /><br /><br /><br /><br /> Jobs<br /><br /><br /> http://hotjobs.yahoo.com/<br /><br /><br /><br /><br /> Loans<br /><br /><br /> http://loans.yahoo.com/<br /><br /><br /><br /><br /> Lottery <br /><br /><br /> http://lottery.yahoo.com/<br /><br /><br /><br /><br /> Pets<br /><br /><br /> http://pets.yahoo.com/<br /><br /><br /><br /><br /> Real Estate<br /><br /><br /> http://realestate.yahoo.com/<br /><br /><br /><br /><br /> Small Business<br /><br /><br /> http://smallbusiness.yahoo.com/<br /><br /><br /><br /><br /> Sports<br /><br /><br /> http://sports.yahoo.com/<br /><br /><br /><br /><br /> Tax Info<br /><br /><br /> http://taxes.yahoo.com/<br /><br /><br /><br /><br /> Tickets<br /><br /><br /> http://tickets.yahoo.com/<br /><br /><br /><br /><br /> Weather<br /><br /><br /> http://weather.yahoo.com/<br /><br /><br /><br /><br /> Yellow Pages<br /><br /><br /> http://yp.yahoo.com/<br /><br /><br /> As you can see, Yahoo! is home to an impressive amount of information, and <br /> knowing how to tap into what's available can help you make your data more <br /> accessible to you.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 23. Track Your Investments<br /><br /><br /><br /><br /><br /> Yahoo! Finance can help you track the performance of your stocks, bonds, <br /> or mutual funds.<br /><br /><br /> Financial information that was once available only to brokers and Wall <br /> Street insiders is now available to anyone in the world with an Internet <br /> connection. Yahoo! Finance collects much of the information available <br /> about stocks, bonds, and mutual funds into a single site, and it's a <br /> fantastic resource for do-it-yourself investors. As financial guru Andrew <br /> Tobias put it, "You should manage your own money. No one is going to care <br /> about it as much as you." Managing your own investments means there's more <br /> work for you, but the online tools at Yahoo! Finance can help you get a <br /> picture of where your investments stand.<br /><br /><br /> 2.2.1. Get Quotes and News<br /><br /><br /> Yahoo! Finance is well known for providing stock quotes and business news. <br /> (Even Yahoo! competitor Google sends people to Yahoo! Finance for more <br /> detailed information when they look up a ticker symbol.) Simply type a <br /> ticker symbol into the form at the top of the page at Yahoo! Finance <br /> (http://finance.yahoo.com/) to see a detailed page with the current <br /> trading price (delayed 20 minutes) and information about the stock's <br /> activity for the day. Figure 2-1 shows the stock detail page for Yahoo's <br /> symbol (YHOO).<br /><br /><br /><br /><br /> Figure 2-1. Details about YHOO at Yahoo! Finance<br /><br /><br /><br /><br /><br /> Running down the left side of the page, you'll find links to detailed <br /> information about the stock, including a message board for discussing the <br /> stock with other Yahoo! users, lists of company insiders who have sold <br /> stock recently, opinions on the stock from dozens of industry analysts, <br /> SEC filings, and a history of the stock performance.<br /><br /><br /><br /><br /> Feeling lost in all of the financial technical jargon? Yahoo! <br /> Finance provides a detailed glossary of financial terms at <br /> http://biz.yahoo.com/f/g.<br /><br /><br /><br /><br /><br /><br /> Just below the numbers is a list of any current headlines about the <br /> company from about 50 different news sources, and they're all enabled by <br /> default. You can click the Edit link in the headlines title to add or <br /> remove news sources from the headlines.<br /><br /><br /> Yahoo! Finance also offers RSS feeds for company news, so you can monitor <br /> media mentions of your favorite companies in My Yahoo! or your preferred <br /> newsreader. To put together an RSS feed, visit the feed generator at <br /> http://biz.yahoo.com/rss.html. From there, you can enter one or more stock <br /> symbols, and Yahoo! will assemble the proper URL. If you're a <br /> do-it-yourself URL builder, you can assemble a URL in this format:<br /> http://finance.yahoo.com/rss/headline?s=insertstocksymbol(s)<br /><br /><br /> To watch more than one company, separate the stock symbols with commas. So <br /> an RSS feed combining news for Yahoo!, Amazon, Microsoft, and eBay looks <br /> like this:<br /> http://finance.yahoo.com/rss/headline?s=yhoo,amzn,msft,ebay<br /><br /><br /> In addition to the daily charts and numbers for U.S. stocks, Yahoo! <br /> Finance offers some other interesting information:<br /><br /><br /><br /><br /> After-hours quotes<br /><br /><br /> Even when the markets close for the day, Yahoo! gathers information about <br /> after-hours trading and displays it on the stock's detail page.<br /><br /><br /><br /><br /> Stock options<br /><br /><br /> Yahoo! offers information about stock options that you can look up via the <br /> company's stock symbol. Click Options on the left side of a stock's detail <br /> page. You can also add options to your portfolio by using the symbols on <br /> the options page.<br /><br /><br /><br /><br /> International stock exchanges<br /><br /><br /> You can access markets around the world at http://biz.yahoo.com/ifc. The <br /> Yahoo! International Finance Center includes links to localized Yahoo! <br /> Finance pages and financial facts about hundreds of countries.<br /><br /><br /> 2.2.2. Build a Portfolio<br /><br /><br /> At its most basic, a portfolio is a way to watch a group of your favorite <br /> stocks, bonds, or mutual funds. Say you have an employee 401(k) plan <br /> invested in some mutual funds, a personal retirement account, and maybe <br /> some stocks at a brokerage. All of these would have their own statements <br /> at various web sites, with numerous logins to remember. If you wanted to <br /> track their progress on a regular basis, you'd need to visit all of the <br /> sites. With Yahoo! Finance, you can pull financial data together from <br /> various sources and turn it into a one-stop site for tracking your net <br /> worth.<br /><br /><br /> You can set up a portfolio by clicking the Create link next to the <br /> Portfolios heading in the upper-left corner of the Yahoo! Finance page <br /> (http://finance.yahoo.com/). Or you can browse to <br /> http://edit.finance.yahoo.com/eh and click the "Track a symbol watch list" <br /> link. Give your group of stocks a name, choose the currency you'd like to <br /> see the stocks in (U.S. Dollar is the default), and then add stock ticker <br /> symbols to the form, separated by spaces.<br /><br /><br /><br /><br /> If you don't know the symbol for a company or mutual fund <br /> you'd like to track, look it up at http://finance.yahoo.com/l.<br /><br /><br /><br /><br /><br /><br /> For example, you could add YHOO AMZN MSFT EBAY to the form to track the <br /> stock prices of Yahoo!, Amazon, Microsoft, and EBay.<br /><br /><br /> Click Finished, and you can view your portfolio at any time by clicking <br /> the Quotes link in the upper-right corner of the Yahoo! Finance home page. <br /> The basic view of your portfolio includes the ticker symbol, last trade, <br /> change, and volume, as shown in Figure 2-2.<br /><br /><br /><br /><br /> Figure 2-2. A simple stock portfolio at Yahoo! Finance<br /><br /><br /><br /><br /><br /> If you use My Yahoo! to track information, you can also watch your <br /> portfolios there. Click Add Content at the top of the page at <br /> http://my.yahoo.com/ and then click Yahoo! Services on the list of <br /> choices. Find Stock Portfolios on the list and click the Add button. You <br /> should find your stock watch list as a content box on your My Yahoo! page, <br /> as shown in Figure 2-3.<br /><br /><br /><br /><br /> Figure 2-3. A stock portfolio on My Yahoo!<br /><br /><br /><br /><br /><br /> You can also track your portfolio via a cell phone with a web connection. <br /> Point your phone to http://mobile.yahoo.com/ and choose Finance My <br /> Portfolios. You'll see a list of your stocks, just like you'd find on the <br /> web site. Figure 2-4 shows the example portfolio on Yahoo! Mobile.<br /><br /><br /><br /><br /> Figure 2-4. A stock portfolio on Yahoo! Mobile<br /><br /><br /><br /><br /><br /> As you browse the web site, you'll see Set Alert links in various places. <br /> Click the link to set an alert for a particular stock that can be sent to <br /> an email address, Yahoo! Instant Messenger, or a cell phone. With an alert <br /> set [Hack #50], you can be sure you'll be notified if there are any wild <br /> swings in the stocks you're watching.<br /><br /><br /> To take your saved portfolios a step further, you can also add information <br /> such as the number of shares you own of each stock and the price you <br /> purchased them at. Click the Edit link next to the Quotes heading on the <br /> Yahoo! Finance page and scroll down to Advanced Features. From here, you <br /> can choose which personalized information you'd like to add.<br /><br /><br /><br /><br /> Yahoo! Finance pages are not encrypted and could be subject to <br /> eavesdropping. If you consider your personal financial <br /> holdings confidential, do not add the number of shares, <br /> purchase price, or any personally identifiable information to <br /> your Yahoo! portfolios.<br /><br /><br /><br /><br /><br /><br /> Once you've added the number of shares you own, you can click the <br /> Performance link above the basic view of your portfolio to see the value <br /> of your holdings. If you included your purchase price, the performance <br /> page will also tell you how much you've gained or lost since buying each <br /> stock in the portfolio.<br /><br /><br /> Yahoo! doesn't offer brokerage services such as buying and selling stocks, <br /> so you'll always need to update your portfolio by hand after you've made <br /> any trades.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 24. Build Your Own Stock Update Email<br /><br /><br /><br /><br /><br /> Receive simple stock price updates via emailon your own schedulewith a bit <br /> of Perl scripting.<br /><br /><br /> If you have money in stocks, bonds, or mutual funds, you know how <br /> addictive it can be to check the current value of your investments. Some <br /> people enjoy the roller-coaster ride of watching their money ebb and flow <br /> throughout the day, while others take the long view and just want an <br /> occasional look at how their portfolio is progressing. Somewhere in the <br /> middle of these extremes lie daily stock updates. They can let you keep <br /> tabs on your portfolio on a regular basis without the ulcers caused by <br /> minute-to-minute checks.<br /><br /><br /> Yahoo! Finance offers a daily update email that is easy to set up. Log in <br /> to Yahoo!, go to http://finance.yahoo.com/, and look for the Portfolios <br /> box at the top of the page. On the right side of the box, click the <br /> Customize Finance link, and then click Daily Update from the following <br /> page. From there, you can sign up for the email and set some preferences, <br /> including how often you want to receive the email: every market day or <br /> weekly.<br /><br /><br /> The email itself is HTML-formatted like a web page and includes top <br /> finance stories from the day, any changes in your portfolios (if you have <br /> them set up), and announcements related to Yahoo! Finance. It's a good way <br /> to get a snapshot of the market from the day and looks like the email in <br /> Figure 2-5.<br /><br /><br /><br /><br /> Figure 2-5. Yahoo! Finance Daily Update email<br /><br /><br /><br /><br /><br /> If you'd like to just get down to your stock prices, or have a bit more <br /> control over when the email is sent, you'll have to do a bit of scripting. <br /> Luckily, Yahoo! Finance gives you all of the information you need to make <br /> it happen; you just need to tie it together into a single email with a bit <br /> of Perl.<br /><br /><br /> This example relies on the fact that you can look up any ticker symbol via <br /> a Yahoo! Finance URL. For example, all of the day's stock information <br /> about YHOO (the ticker symbol for Yahoo!, Inc.) is here: <br /> http://finance.yahoo.com/q?s=YHOO. On each stock detail page like this <br /> one, you'll find a tiny Download Data link under the quote data. This <br /> gives you a text-only file with the relevant information for that stock in <br /> a format suitable for importing into a spreadsheet. The raw data itself is <br /> a series of comma-separated values that looks like this:<br /><br /><br /> "YHOO",31.57,"3/24/2005","3:17pm",+0.70,31.91,32.09,31.49,20544748<br /><br /><br /><br /><br /> Though the intended destination for this data is a spreadsheet, you can <br /> use the same file to build your own email containing only the stock <br /> information you want to see.<br /><br /><br /> 2.3.1. The Code<br /><br /><br /> This example has a few nonstandard Perl modules that you'll need to have <br /> installed before you can run it. The script uses LWP::Simple to fetch the <br /> stock data, Number::Format to make the stock prices look nice, and <br /> NET::SMTP to send the email.<br /><br /><br /> You'll also need to replace a few values in the script with your own data. <br /> Set $smtp_server to your email server, $from_email to an address with <br /> permissions to send email on that server, and $to_email to the email <br /> address where you'd like to receive the stock update. And most <br /> importantly, set the list of stocks you'd like to track by adding their <br /> ticker symbols on this line:<br /><br /><br /> my @stocks = qw(insert ticker symbols separated by spaces);<br /><br /><br /><br /><br /> So if you want to track Yahoo!, Amazon, eBay, and Microsoft as this <br /> example script does, you'll want this line to look like this:<br /><br /><br /> my @stocks = qw(YHOO AMZN EBAY MSFT);<br /><br /><br /><br /><br /> Save the following code to a file called stock_update.pl:<br /><br /><br /> #!/usr/bin/perl<br /> # stock_update.pl<br /> # A script to download Yahoo! Finance info about stocks<br /> # and send it via email<br /> # Usage: stock_update.pl<br /><br /><br /> use LWP::Simple;<br /> use Number::Format;<br /> use Net::SMTP;<br /> use strict;<br /><br /><br /> # Set your stocks<br /> my @stocks = qw(YHOO AMZN EBAY MSFT);<br /><br /><br /> # Set output file<br /> my $file = "quick_stock_update.txt";<br /> open(FILE, ">$file")||die "Can't open $file";<br /><br /><br /> # Set email info<br /> my $subject = "Quick Stock Update";<br /> my $smtp_server = "insert your SMTP server";<br /> my $from_email = 'insert your from email';<br /> my $to_email = 'insert your to email';<br /><br /><br /> # Define some variables<br /> my $stock_symbol;<br /> my $last_trade_f;<br /> my $trade_date;<br /> my $change;<br /><br /><br /> # Define the file header<br /> format FILE_TOP=<br /> Quick Stock Update<br /> ------------------------------------<br /> Symbol Price Date Change<br /> ------------------------------------<br /> .<br /><br /><br /> # Define the line-item details<br /> format FILE=<br /> @<<<<< @>>>> @|||||||||| @>>>>><br /> $stock_symbol, $last_trade_f, $trade_date, $change<br /> .<br /><br /><br /> # Loop through stocks<br /> foreach my $stock (@stocks) {<br /> my $stock_request = "http://finance.yahoo.com/d/quotes.csv?s=".<br /> "$stock&f=sl1d1t1c1ohgv&e=.csv";<br /> my $stock_data = get($stock_request);<br /><br /><br /> ($stock_symbol, my $last_trade, $trade_date, my $trade_time,<br /> $change, my $open, my $high, my $low, my $volume)<br /> = split(/,/, $stock_data);<br /><br /><br /> my $x = new Number::Format(-int_curr_symbol => '');<br /> $last_trade_f = $x->format_number($last_trade,2,2);<br /> $trade_date =~ s/"//g; $trade_time =~ s/"//g;<br /> $stock_symbol =~ s/"//g;<br /> write FILE;<br /> }<br /> # Close output file<br /> close(FILE);<br /><br /><br /> # Open output file for reading<br /> open(FILE, "$file")||die "Can't open $file";<br /><br /><br /> # Send the file in email<br /> my $smtp = Net::SMTP->new($smtp_server);<br /> $smtp->mail($from_email);<br /> $smtp->to($to_email);<br /> $smtp->data( );<br /> $smtp->datasend("From: $from_email\n");<br /> $smtp->datasend("To: $to_email\n");<br /> $smtp->datasend("Subject: $subject\n");<br /> $smtp->datasend('Content-Type: text/plain; charset="iso-8859-1"');<br /> $smtp->datasend("\n\n");<br /> while(<FILE>) {<br /> $smtp->datasend("$_");<br /> }<br /> $smtp->dataend( );<br /> $smtp->quit;<br /><br /><br /> # Close output file<br /> close(FILE);<br /><br /><br /><br /><br /> As you can see in the section labeled Loop through stocks, there's quite a <br /> bit more data in the Yahoo! Download Data file than this script makes use <br /> of for the email. The email sent by this script displays the ticker <br /> symbol, latest price, date of the last trade, and the change in price for <br /> the day. But you'll also find good tidbits in the data file, such as the <br /> opening price, high and low for the day, and the volume of the stock <br /> traded. This data is available for use, so if it's something you're <br /> interested it, you can tweak this script to show more.<br /><br /><br /><br /><br /> Email is not a secure way to communicate, so be careful about <br /> what information you expose in your email messages. Think of <br /> email as a postcard that others might be able to read rather <br /> than a sealed envelope that only its intended recipient opens. <br /> An individual email can pass through several servers on the <br /> way to its destination, and there are plenty of opportunities <br /> for others to eavesdrop, so email is not the place for any <br /> sensitive financial information.<br /><br /><br /><br /><br /><br /><br /> 2.3.2. Running the Hack<br /><br /><br /> To run this script once, you can just call it from the command line:<br /><br /><br /> perl stock_update.pl<br /><br /><br /><br /><br /> But the value of the script is in running it on a schedule you're <br /> comfortable with. Using Windows Scheduler, you can set it to run every <br /> weekday after the market closes, once a week, or once a quarter. If you <br /> really want to feel the bumps of the market, you could set this to run <br /> every hour.<br /><br /><br /> The email itself is plain text, so you should see something like the <br /> message shown in Figure 2-6 in your inbox.<br /><br /><br /><br /><br /> Figure 2-6. Custom stock update email<br /><br /><br /><br /><br /><br /> While not nearly as aesthetically pleasing and packed with information as <br /> the standard Yahoo! Daily Update, this quick email has a certain <br /> minimalist charm. And this bit of scripting can get you exactly the <br /> information you want, when you want it.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 25. Download Financial Data Using Excel Web Queries<br /><br /><br /><br /><br /><br /> When a web site doesn't offer a downloadable file of the data you want, <br /> avoid manual data entry by using Microsoft Excel's web query feature.<br /><br /><br /> These days, you can find most of the data you need to analyze investments <br /> on the Web, and much of it for little or no cost. However, putting that <br /> data into a spreadsheet where you can use it is another matter. Some web <br /> sites include links to download spreadsheets, text files of prices, or <br /> other financial data to your computer. Other sites offer subscriptions to <br /> downloadable data. However, if you can accept with equanimity the <br /> inevitable web page changes and the subsequent rework of your Excel <br /> spreadsheets that those changes require, you can create your own tools to <br /> download data from the Web. Excel web queries are easy to use and capture <br /> data by taking advantage of tables in a web page's HTML source. You can <br /> use web queries to feed your financial formulas and produce new investment <br /> studies or update portfolio management tables in a matter of seconds.<br /><br /><br /><br /><br /> Web queries are available in Excel for Windows 2000 and later, <br /> or in Excel X for Macintosh.<br /><br /><br /><br /><br /><br /><br /> 2.4.1. Creating an Excel Web Query<br /><br /><br /> Web queries are pretty slick. The only information a web query needs is <br /> the address (URL) of the web page and the tables on that page that contain <br /> the data that you want. When you specify a URL in the New Web Query dialog <br /> box, the web page appears in the dialog box. In Excel XP and 2003, arrows <br /> point to each table on the page. After you select the tables to query, <br /> Excel extracts the labels and values from those tables and adds them to <br /> cells in a worksheet. With one shortcut command, you can refresh the data <br /> from the Web. To illustrate a web query, let's use an easy examplethe <br /> price quote for a stock or mutual fund from Yahoo! Finance.<br /><br /><br /><br /><br /> Web queries are tailored to the configuration of a specific <br /> web page. If the web site changes its URL or reformats data <br /> into different tables, you must recreate your web queries.<br /><br /><br /><br /><br /><br /><br /> To add a web query to an existing worksheet in an Excel workbook, open the <br /> workbook and select the tab for the worksheet you want. To create a new <br /> web query in Excel XP, follow these steps:<br /><br /><br /><br /> Choose Data Import External Data New Web Query. The New Web Query dialog <br /> box opens, displaying the home page you use in Internet Explorer. The <br /> toolbar in the New Web Query dialog box includes an Address drop-down <br /> list, which is automatically populated with yourURL History list from <br /> Internet Explorer. The toolbar has other frequently used browser <br /> commands, such as Back, Forward, and Refresh. <br /><br /><br /><br /> If you've recently accessed the web page you want to query, click the <br /> Address arrow to display your URL History list and select the desired <br /> web page. Otherwise, you can type the URL for the web page in the <br /> Address box and click Go. For example, to use Yahoo! Finance, type <br /> http://finance.yahoo.com/ in the Address box. <br /><br /><br /> You can browse in the New Web Query dialog box, so you don't have to <br /> enter the URL for a specific page. For example, after you navigate to <br /> the Yahoo! Finance home page, you can type the ticker symbol for the <br /> stock you want in the Enter Symbol(s) box and click Goall on the Yahoo! <br /> Finance web page in the dialog box browser. The browser in the dialog <br /> box displays the quote page for the stock ticker you typed. <br /><br /><br /><br /><br /> Make sure you click the Go button on the Yahoo! Finance web <br /> page, not the Go button in the New Web Query toolbar.<br /><br /><br /><br /><br /><br /><br /><br /> In the New Web Query dialog box, the browser positions a yellow box with <br /> a black arrow next to every table on the web page. To select a table, <br /> position the mouse pointer over the yellow box to the left of the data <br /> you want. Excel outlines the table with a thick line so you can verify <br /> the data that the query will return. If you picked the correct table, <br /> click the yellow box. It changes to a green box with a checkmark, as <br /> shown in Figure 2-7. Continue to click tables until you've selected all <br /> the ones you want. <br /><br /><br /><br /><br /> If you don't see yellow boxes in the browser, click the Show <br /> Icons button on the New Web Query toolbar.<br /><br /><br /><br /><br /><br /><br /><br /> Click Import. The Import Data dialog box appears. <br /><br /><br /><br /> To insert the results of the query into the current worksheet, select <br /> the Existing Worksheet option. By default, the address for the currently <br /> selected cell appears in the box. Type another cell address to specify <br /> where you want to import the data on the worksheet. <br /><br /><br /> To create a new worksheet for the query, select the New Worksheet <br /> option. <br /><br /><br /><br /> Click OK to import the data into the worksheet. <br /><br /><br /> Although the cells don't look like they have superpowers, they are <br /> associated with your web query. You can refresh the data from the <br /> associated web page by right-clicking any cell in the web query and <br /> choosing Refresh Data from the shortcut menu, as illustrated in Figure <br />2-8.<br /><br /><br /><br /><br /> Figure 2-7. Visual feedback helps you select tables for a web query<br /><br /><br /><br /><br /><br /><br /><br /> Figure 2-8. Refresh web query data with the Refresh Data command<br /><br /><br /><br /><br /><br /> 2.4.2. Making a Web Query Work for Any Ticker Symbol<br /><br /><br /> The web query you just created is pretty handy. You can update the quote <br /> for a stock you own or watch by refreshing its data. However, as you <br /> manage your investment portfolio, you must constantly evaluate new stocks <br /> and mutual funds. Creating a new web query for each investment prospect <br /> would become downright tiresome. Wouldn't it be cool if you could make <br /> this query download data for a new prospect simply by typing its ticker <br /> symbol into a worksheet cell? Well, you can, and it's easy when you follow <br /> these steps:<br /><br /><br /><br /> To customize a web query, first save it as a file. Right-click any cell <br /> for the web query in the worksheet and choose Edit Query from the <br /> shortcut menu. In the Edit Web Query dialog box, make sure that the <br /> tables you want show green boxes with checkmarks, and then click the <br /> Save As icon on the toolbar (see Figure 2-9). In the Save As dialog box, <br /> navigate to the folder in which you want to store the web query, type a <br /> name for the file (such as Yahoo_Price_Quote) in the File Name box and <br /> click Save. <br /><br /><br /><br /><br /> Figure 2-9. Click the Save As icon to save a web query to a file <br /> <br /><br /><br /><br /><br /><br /> Next, add the ticker symbol as a parameter to the saved web query file. <br /> Navigate to the saved web query file in Windows Explorer (Yahoo_ <br /> Price_Quote.iqy in this example), right-click it, and choose "Edit with <br /> Notepad" from the shortcut menu. The third line in the file specifies <br /> the URL for the web page. The URL for a Yahoo! Finance quote page, like <br /> most web pages with data for a specific investment, includes the ticker <br /> symbol of the stock or mutual fund quoted. In Example 2-1, the ticker <br /> symbol low represents Lowe's. <br /><br /><br /> Example 2-1. The URL for a web page with financial data often includes <br /> the investment's ticker symbol <br /><br /><br /> http://finance.yahoo.com/q?s=low <br /><br /><br /><br /><br /><br /> To make the web query download the data for the ticker symbol you <br /> specify, replace the ticker symbol in the URL with ["symbol", "Enter <br /> Symbol"]. The URL in the web query should look like the line in Example <br /> 2-2. <br /><br /><br /> Example 2-2. Modifying the URL in a web query to prompt for the ticker <br /> symbol <br /><br /><br /> http://finance.yahoo.com/q?s=["symbol", "Enter ticker symbol"] <br /><br /><br /><br /><br /><br /> To save the web query, choose File Save. <br /><br /><br /> Now, use this new web query in a spreadsheet to retrieve data based on the <br /> ticker symbol you specify:<br /><br /><br /><br /> Type a ticker symbol in a worksheet cellfor example, use cell A2 on <br /> Sheet1. <br /><br /><br /><br /> To use the web query to import data, choose Data Import External Data <br /> Import Data. <br /><br /><br /><br /> In the Select Data Source dialog box, navigate to the folder that <br /> contains your saved web query file and double-click it. <br /><br /><br /><br /> In the Import Data dialog box, select an option to specify whether to <br /> use the current worksheet or create a new one. If you select the <br /> Existing Worksheet option, type the cell address that denotes the <br /> upper-left corner of the cell range where you want the data imported in <br /> the Existing Worksheet box. <br /><br /><br /><br /> Click Parameters. In the Parameters dialog box, select the "Get the <br /> value from the following cell" option, click the box immediately below <br /> the option, and then select the worksheet cell that contains the ticker <br /> symbol (in this example, A2). <br /><br /><br /><br /><br /> The "Get the value from the following cell" option does not <br /> accept named cells. You must either select the cell that <br /> contains the parameter value in the worksheet or type the cell <br /> address using column and row references, such as A2.<br /><br /><br /><br /><br /><br /><br /><br /> If you want the web query to retrieve new values automatically from the <br /> Web when you enter a new ticker symbol, check the "Refresh automatically <br /> when cell value changes" checkbox. <br /><br /><br /><br /> Click OK twice to import the data. In this example, when you type a new <br /> ticker symbol in cell A2 and press Enter or an arrow key to navigate <br /> away from the ticker symbol cell, the web query refreshes the web query <br /> cells with values for the new ticker symbol. <br /><br /><br /><br /><br /> When a web query uses parameters, you can use the same web <br /> query text file to import data for multiple companies into <br /> different areas of a worksheet. To reuse a web query text <br /> file, select the cell in the upper-left corner of the cell <br /> range into which you want to import data, and then repeat <br /> steps 17.<br /><br /><br /><br /><br /><br /><br /> 2.4.3. Hacking the Hack<br /><br /><br /> After your web query successfully grabs the data you want from the Web, <br /> you can feed those values into a data summary worksheet or into formulas <br /> on other worksheets. You could name the cells within the web query cell <br /> range, but that could throw your calculations off if the query returns <br /> values in a different order. By using a function such as VLOOKUP instead, <br /> you can find the text label that identifies the value you want, regardless <br /> of the cell. For example, suppose you want to use values from a price <br /> query to compare the current price to the 52-week high and low prices. In <br /> Figure 2-10, the Current Price and 52-week range cells use VLOOKUP to find <br /> values based on labels, as the formula bar shows.<br /><br /><br /><br /><br /> Figure 2-10. The VLOOKUP function finds values based on labels, not cell <br /> addresses<br /><br /><br /><br /><br /><br /> Take a look at the worksheets in Figure 2-10 to see how this works. To <br /> obtain the current price from the Yahoo! price web query, find the row <br /> that has the label Last Trade: in column A on the Price Query worksheet. <br /> Then, retrieve the value in that row from column B. The formula to perform <br /> these tasks is in cell B3 on the Price Check worksheet and is also shown <br /> in Example 2-3.<br /><br /><br /> Example 2-3. Using VLOOKUP to find a value in one column based on the <br /> label in another column<br /><br /><br /> Current Price = VLOOKUP("Last Trade:",'Price Query'!$A:$B,2,FALSE)<br /><br /><br /><br /><br /><br /><br /> In Example 2-3 and other examples of Excel formulas throughout <br /> the book, the text to the left of the equals sign (=) <br /> identifies the information being calculated or retrieved by <br /> the Excel formula. To enter the formula in a cell in a <br /> spreadsheet, enter the formula beginning with the equals sign.<br /><br /><br /><br /><br /><br /><br /> To find the 52-week price range, use 52wk Range: as the lookup_ value, as <br /> shown in Example 2-4.<br /><br /><br /> Example 2-4. Another example of VLOOKUP<br /><br /><br /> Price Range = VLOOKUP("52wk Range:",'Price Query'!$A:$B,2,FALSE)<br /><br /><br /><br /><br /><br /><br /> Web queries come with a built-in name that represents the cell <br /> range that contains the result of the web query. To view or <br /> modify this name, right-click within the web query results and <br /> choose Data Range Properties from the shortcut menu. If you <br /> specify the web query name as the table_array parameter of the <br /> VLOOKUP function, the cell range adjusts automatically to <br /> match the web query results.<br /><br /><br /><br /><br /><br /><br /> Finally, you can use some nested text functions to extract the high and <br /> low values out of the 52-week price range, as shown in Example 2-5for <br /> instance, to calculate the percentage change from the stock's high price <br /> to its current value. You can use functions such as RIGHT, LEFT, LEN, and <br /> FIND to parse the prices out of the price range. The VALUE function <br /> converts the text to a numeric value.<br /><br /><br /> Example 2-5. Using text functions to extract information from text strings<br /><br /><br /> High Price = VALUE(RIGHT(price_range,LEN(price_range)-FIND("- <br /> ",price_range)-1))<br /> Low Price = VALUE(LEFT(price_range,FIND("- ",price_range)-1))<br /> Percent Change = (Current Price - High Price)/High Price<br /><br /><br /><br /><br /> Bonnie Biafore<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 26. Convert Currencies with One Click<br /><br /><br /><br /><br /><br /> Yahoo! Finance can tell you how many euros there are in a U.S. dollar, and <br /> a little JavaScript can speed up the answer.<br /><br /><br /> While browsing the Web, you might find yourself in some unusual places. <br /> You're potentially just a click away from any site that exists, including <br /> online stores large and small, across the globe. The next time you're <br /> reading about a bleeding-edge European cell phone from your home in the <br /> United States, you might want to find out just how much that £500 would be <br /> in U.S. dollars.<br /><br /><br /> Yahoo! Finance's Currency Converter (http://finance.yahoo.com/currency) <br /> can give you the answer. From this page, you can select a currency to <br /> convert from, a currency to convert to, and the amount of currency you'd <br /> like to convert.<br /><br /><br /> This is a fairly painless process, but it still involves leaving your <br /> review site, opening a new browser window, and generally losing focus from <br /> all of those cutting-edge features of that smart phone you're really <br /> interested in.<br /><br /><br /> Because Yahoo!'s Currency Converter handles everything in the URL query <br /> string, you can write some JavaScript to automate this process and find <br /> out what you would need to pay, with just one click. For example, the <br /> following URL goes directly to the Yahoo! page that converts £500 into <br /> U.S. dollars:<br /> http://finance.yahoo.com/currency/convert?amt=500&from=GBP&to=USD<br /><br /><br /> The query string variables are fairly self-explanatory:<br /><br /><br /><br /><br /> amt<br /><br /><br /> The amount of currency to convert<br /><br /><br /><br /><br /> from<br /><br /><br /> The three-letter abbreviation for the currency you're converting from<br /><br /><br /><br /><br /> to<br /><br /><br /> The three-letter abbreviation for the currency you're converting to<br /><br /><br /> By changing these values in the URL, you can change the results page. <br /> Here's the URL for converting 100 U.S. dollars into British pounds:<br /> http://finance.yahoo.com/currency/convert?amt=100&from=USD&to=GBP<br /><br /><br /> Here's just a handful of the 157 currencies Yahoo! currently supports:<br /><br /><br /><br /><br /> USD<br /><br /><br /> U.S. dollar<br /><br /><br /><br /><br /> EUR<br /><br /><br /> Euro<br /><br /><br /><br /><br /> CAD<br /><br /><br /> Canadian dollar<br /><br /><br /><br /><br /> AUD<br /><br /><br /> Australian dollar<br /><br /><br /><br /><br /> JPY<br /><br /><br /> Japanese yen<br /><br /><br /><br /><br /> INR<br /><br /><br /> Indian rupee<br /><br /><br /><br /><br /> NZD<br /><br /><br /> New Zealand dollar<br /><br /><br /><br /><br /> CHF<br /><br /><br /> Swiss franc<br /><br /><br /><br /><br /> ZAR<br /><br /><br /> South African rand<br /><br /><br /> You can find a list of all the currencies and abbreviations that Yahoo! <br /> supports in the drop-down list at the Currency Converter page.<br /><br /><br /> 2.5.1. The Code<br /><br /><br /> This hack will let you highlight a currency amount on a web page and <br /> convert it from British pounds to U.S. dollars. It's a piece of JavaScript <br /> that resides in a browser bookmark, otherwise known as a bookmarklet. <br /> Bookmarklets run when you click the bookmark, and they can get information <br /> from the current page you're browsing. In this case, the information the <br /> bookmarklet gets is the currency amount you've highlighted.<br /><br /><br /> The code for bookmarklets isn't very pretty to look at, so here's some <br /> nicely formatted JavaScript that approximates the bookmarklet functions:<br /><br /><br /> // Dissected JavaScript bookmarklet for one-click Currency Conversion<br /><br /><br /> // Set d to the document object as a shortcut<br /> var d = document;<br /><br /><br /> // Set t to the currently selected text, if available<br /> var t = w.selection?w.selection.createRange( ).text:w.getSelection( );<br /><br /><br /> // Test to make sure t is a number<br /> t = parseFloat(t);<br /> If (t != parseFloat(t)) {<br /> // If not, warn that the value isn't numeric<br /> alert('Please highlight a numeric value.');<br /> } else {<br /> // Build the URL<br /> var url = http://finance.yahoo.com/currency/convert?';<br /> url += 'amt='+escape(t)+'&';<br /> url += 'from=GBP&';<br /> url += 'to=USD';<br /><br /><br /> // And open in a new window<br /> window.open(url,<br /> '_blank',<br /> 'width=480,height=440,status=yes,resizable=yes,scrollbars=yes');<br /> }<br /><br /><br /><br /><br /> Because bookmarklets are compact, this is the actual code you'll need to <br /> use:<br /><br /><br /> javascript:d=document;t=d.selection?d.selection.createRange( ).text:d.<br /><br /><br /><br /> getSelection( );t=parseFloat(t);if(t!=parseFloat(t)){alert('Please <br /><br /><br /><br /> highlighta numeric value.')}else{url='http://finance.yahoo.com/<br /><br /><br /><br /> currency/convert?amt='+escape(t)+'&from=GBP&to=USD';void(window.open(url,<br /><br /><br /><br /> '_blank','width=480,height=440,status=yes,resizable=yes,scrollbars=yes'))}<br /><br /><br /><br /><br /> 2.5.2. Running the Hack<br /><br /><br /> Running the code is just a matter of adding a bookmark to your preferred <br /> browser. Once a new bookmark exists, replace the URL with the JavaScript. <br /> Also, give the bookmarklet a descriptive name, such as GBP to USD. Once <br /> the bookmarklet is set, when you want to perform a currency conversion, <br /> you can highlight a numeric value on any page and click the bookmark. For <br /> example, Figure 2-11 shows a mobile phone site that mentions a price of <br /> £500.<br /><br /><br /><br /><br /> Figure 2-11. A browser with the currency conversion bookmarklet<br /><br /><br /><br /><br /><br /> Highlighting the amount and clicking the GBD to USD bookmark opens a new <br /> window with the conversion at Yahoo! Finance, as shown in Figure 2-12.<br /><br /><br /><br /><br /> Figure 2-12. The new currency conversion window<br /><br /><br /><br /><br /><br /> Now you know that (at the time of this writing) £500 equals US$890.47. But <br /> more importantly, you'll have this information a click away the next time <br /> you're browsing exotic locales across the Web.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 27. Do the Math with Yahoo! Calculators<br /><br /><br /><br /><br /><br /> The next time someone tells you to "do the math," try a Yahoo! Calculator.<br /><br /><br /> Every computer has a simple calculator application, which you probably use <br /> to do addition and subtraction. Yahoo! can take the place of this <br /> calculator, and Yahoo! Calculators can give you answers to complex <br /> financial questions.<br /><br /><br /> For the simplest types of calculations, you can use any Yahoo! Search <br /> form. Type 237 + 13 into a Yahoo! Search form and you'll find the answer <br /> at the top of the search results. You can also group together more complex <br /> functions with parentheses, as shown in Figure 2-13.<br /><br /><br /><br /><br /> Figure 2-13. Simple math in a Yahoo! Search result<br /><br /><br /><br /><br /><br /> Yahoo! Search forms can also handle unit conversion with the convert <br /> shortcut. Type convert 25 miles to kilometers into a Yahoo! Search form, <br /> and the top result will tell you the answer is 40.234 kilometers. And the <br /> time in shortcut will do some quick time zone math. Type time in London, <br /> and you'll know whether it's too late or too early to call someone there.<br /><br /><br /> In addition to the simple calculators built in to Yahoo! Search, there are <br /> more sophisticated ones that help you answer everything from how to pay <br /> down your debt to which stock to invest in, providing charts and detailed <br /> explanations to help you make sound financial decisions. Computers are <br /> calculators, but they don't necessarily tell you what to calculate when <br /> you want answers to complex financial questions. That's where Yahoo! <br /> Calculators can help.<br /><br /><br /> 2.6.1. Anatomy of a Yahoo! Calculator<br /><br /><br /> Before you start calculating how much credit you can receive based on the <br /> value of your house, take a minute to orient yourself to the basic Yahoo! <br /> Calculator format. Instead of a traditional calculator with a keypad and <br /> numbers, a Yahoo! Calculator is a questionnaire that you fill in with <br /> relevant values. Filling out a calculator can take some timeespecially <br /> when you have to gather all of the information requiredbut the end result <br /> will give you a sharper picture of your financial situation, which should <br /> help you make informed decisions.<br /><br /><br /> Within each calculator section of a Yahoo! site, you'll find a series of <br /> questions like the ones shown in Figure 2-14, organized by subject.<br /><br /><br /><br /><br /> Figure 2-14. A listing of banking calculators at Yahoo!<br /><br /><br /><br /><br /><br /> Click any question to bring up a calculator that's designed to help you <br /> answer that particular question.<br /><br /><br /> You can navigate within many Yahoo! calculators by clicking tabs running <br /> across the top of the page, as shown in Figure 2-15.<br /><br /><br /> Here's a look at what you'll find behind each tab, but keep in mind that <br /> some calculators will have only some (or none) of these options:<br /><br /><br /><br /><br /> Inputs<br /><br /><br /> This is the web form where you enter your personal data. Many calculators <br /> have sample numbers in the fields already, but you can highlight the <br /> values and enter your own figures.<br /><br /><br /><br /><br /> Results<br /><br /><br /> Once you've entered your personal data, this is where you'll find the <br /> results of the calculations. The results can be displayed as a series of <br /> tables, charts, or sometimes a few paragraphs.<br /><br /><br /><br /><br /> Graphs<br /><br /><br /> In addition to the standard results, many calculators offer additional <br /> graphs that display your calculations in a visual format.<br /><br /><br /><br /><br /> Explanation (or help)<br /><br /><br /> The page behind this tab summarizes the results you've seen in a general <br /> way and explains how you should be using the calculator.<br /><br /><br /><br /><br /> Figure 2-15. The graphs tab on a Yahoo! calculator<br /><br /><br /><br /><br /><br /> There are over a hundred different calculators available at Yahoo!, in a <br /> number of different categories. Here's a look at some of the main subject <br /> areas you can run numbers for and where you can find the calculators.<br /><br /><br /> 2.6.2. Saving and Investing<br /><br /><br /> Whether you're fine-tuning your retirement plans or trying to pay off your <br /> credit cards, there are a number of calculators to help you project and <br /> strategize.<br /><br /><br /> 2.6.2.1. Banking.<br /><br /><br /> You'll find calculators that deal with credit cards, home equity, <br /> individual retirement accounts, and general savings at <br /> http://banking.yahoo.com/calculators.html. This page contains links to <br /> answers on questions in the following topics:<br /><br /><br /><br /><br /> Credit Cards<br /><br /><br /> See how changes in interest rates, annual fees, and paying off balances <br /> affect your credit card debt.<br /><br /><br /><br /><br /> Credit Line<br /><br /><br /> Find out the difference between a home equity loan and a home equity line <br /> of credit in real numbers.<br /><br /><br /><br /><br /> IRA<br /><br /><br /> Compare different types of retirement accounts and analyze when to begin <br /> saving for retirement.<br /><br /><br /><br /><br /> Savings<br /><br /><br /> Calculate how much you'll need for retirement and review the benefits or <br /> drawbacks to paying off debt compared with saving.<br /><br /><br /> 2.6.2.2. Mutual funds.<br /><br /><br /> You can analyze your current mutual funds or compare potential investments <br /> at http://biz.yahoo.com/edu/fundcalc.html. You'll find the following <br /> topics:<br /><br /><br /><br /><br /> Compare Funds<br /><br /><br /> Compare growth versus income funds, or compare two different funds side by <br /> side.<br /><br /><br /><br /><br /> Determine When to Sell<br /><br /><br /> Look at the financial impact of different selling scenarios: selling <br /> today, waiting one year, and working to achieve a specific return.<br /><br /><br /><br /><br /> Analyze Fee Structures<br /><br /><br /> Look at load versus no-load funds, front versus back-end loads, and the <br /> impact of fees on your return.<br /><br /><br /><br /><br /> Miscellaneous<br /><br /><br /> See the impact of exchange rates on foreign funds and see how fees and <br /> taxes affect when fund costs will be recovered.<br /><br /><br /> 2.6.2.3. Bonds.<br /><br /><br /> Much like mutual fund calculators are bond calculators, which you can find <br /> at http://bonds.yahoo.com/calculator.html. Topics include:<br /><br /><br /><br /><br /> Compare Bonds<br /><br /><br /> Look at tax-exempt versus taxable bonds, zero coupon bonds, discount or <br /> high coupon rate, and compare two bonds side by side.<br /><br /><br /><br /><br /> Purchasing & Selling<br /><br /><br /> Take a look at pricing and returns, including which selling price yields <br /> the desired return, selling before or after one year, and yield to <br /> maturity. You can also see the impact of rate changes on current bond <br /> values.<br /><br /><br /> 2.6.3. Home, Auto, and Education<br /><br /><br /> Your home, car, and college education are some of the biggest purchases <br /> you'll make in your life, and you can find several calculators to help you <br /> plan them.<br /><br /><br /> 2.6.3.1. Mortgage.<br /><br /><br /> In the Mortgage section of Yahoo! Finance, you'll find a series of <br /> questions designed to help you learn about mortgage options. Point your <br /> browser to http://loan.yahoo.com/m/mortcalc.html and you'll find the <br /> following topics:<br /><br /><br /><br /><br /> Starting a Loan<br /><br /><br /> Calculate the benefits of renting versus owning, look at the range of <br /> houses you can afford, and determine how much you'll need to borrow. <br /> Compare loans side by side to see which is better.<br /><br /><br /><br /><br /> Calculating Rates and Payments<br /><br /><br /> Compare fixed and adjustable loans, payment schedules, and see how paying <br /> points to lower the rate will affect your loan.<br /><br /><br /><br /><br /> Refinancing<br /><br /><br /> Find out how much refinancing your home would cost.<br /><br /><br /><br /><br /> More Home Financing Calculators<br /><br /><br /> Calculate tax savings from a home purchase, reduce mortgage insurance <br /> costs, and review the long-term financial savings by making extra <br />payments.<br /><br /><br /> 2.6.3.2. Auto.<br /><br /><br /> The auto calculators at http://loan.yahoo.com/a/autocalc.html are divided <br /> into three concepts:<br /><br /><br /><br /><br /> Type of Purchase<br /><br /><br /> Compare loaning and leasing, and see estimated payments for each. You can <br /> also compare buying new and used cars.<br /><br /><br /><br /><br /> Financial Impact<br /><br /><br /> Calculate monthly payments associated with a car loan, how much money to <br /> put down, and the costs of depreciation.<br /><br /><br /><br /><br /> Loan Specifics<br /><br /><br /> Review the terms of loans, financing versus paying cash, home equity <br /> versus auto loan, and rebates versus special dealer financing.<br /><br /><br /> 2.6.3.3. School financing.<br /><br /><br /> You can plan for the costs associated with college at <br /> http://education.yahoo.com/college/financial_aid/articles/loan_calculators.html. <br /> You'll find calculators to help with monthly budgets, expected family <br /> contribution (EFC) for some loans, and repayment plans.<br /><br /><br /> 2.6.4. Death and Taxes<br /><br /><br /> They're both inevitable, so you may as well get a handle on the numbers.<br /><br /><br /> 2.6.4.1. Life insurance.<br /><br /><br /> You can find calculators dealing with life insurance at <br /> http://insurance.yahoo.com/lh/lhcalc.html. The questions there will help <br /> you understand how life insurance works and what the differences are <br /> between plans. General topics covered include:<br /><br /><br /><br /><br /> Coverage<br /><br /><br /> How much life insurance do you need?<br /><br /><br /><br /><br /> Returns<br /><br /><br /> Find returns for whole life policies, universal policies, and variable <br /> universal policies.<br /><br /><br /><br /><br /> Analysis of the Different Types<br /><br /><br /> Compare term life insurance with whole life, universal life, and variable <br /> universal life.<br /><br /><br /> 2.6.4.2. Taxes.<br /><br /><br /> Get a jump on tax time at http://taxes.yahoo.com/calculators/. Yahoo! <br /> keeps all of the calculators up-to-date for the current tax season, unless <br /> otherwise specified. You'll find help with the following:<br /><br /><br /><br /><br /> Filing Tools<br /><br /><br /> Using TurboTax, these tools help you find deductions, estimate your <br /> refund, and calculate your average tax rate.<br /><br /><br /><br /><br /> Income/Employment Tax Tools<br /><br /><br /> Using TurboTax, find out if you are withholding the right amount from your <br /> paycheck, estimate your take-home pay after deductions, and estimate your <br /> self-employment tax.<br /><br /><br /><br /><br /> Family Life Tools<br /><br /><br /> Use TurboTax to find out how much of a benefit or penalty you'll get from <br /> education expenses, your marital status, and selling a home.<br /><br /><br /><br /><br /> Retirement Tax Planning<br /><br /><br /> Yahoo! calculators look at the impact of potential tax changes and <br /> inflation in the future for your savings and IRAs. Also, calculate how <br /> much you can invest before taxes each year to save some money.<br /><br /><br /> 2.6.5. Calculators Beyond Yahoo!<br /><br /><br /> If you can't find the right calculator at Yahoo!, you might be able to use <br /> Yahoo! to find what you need elsewhere. There are several online <br /> calculator categories in the Yahoo! Directory; just browse to <br /> http://dir.yahoo.com/ and type calculator into the search form. Or go <br /> directly to http://search.yahoo.com/search/dir?p=calculator for a list of <br /> related categories.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 28. Add a Yahoo! Bookmark with One Click<br /><br /><br /><br /><br /><br /> Speed up the process of adding sites to your Yahoo! Bookmarks with a <br /> browser bookmark and a bit of JavaScript.<br /><br /><br /> Yahoo! Bookmarks are an easy way to share a list of web sites across <br /> several computers. If you have a set of sites you like to visit from home, <br /> the office, a friend's house, or any other place you might find yourself <br /> in front of a computer, they'll always be just a few clicks away at your <br /> Yahoo! account, instead of trapped inside your browser at home.<br /><br /><br /> Unfortunately, setting up this list of sites for the first time can be <br /> time-consuming. After logging into My Yahoo!, you must find your bookmarks <br /> (usually in the upper-right corner); click Add; copy and paste the site <br /> URL, name, and any comments into the form; and click the Save button. This <br /> might not sound too labor intensive, but it amounts to quite a few steps <br /> if you're adding more than a few sites.<br /><br /><br /> If you've installed the Yahoo! Toolbar, you might have already experienced <br /> the joy of one-click Yahoo! Bookmarks. On any web page, you can click the <br /> Add Bookmark button to add a site. From then on, the site will be <br /> available at your Yahoo! Bookmarks. If you don't want to install the <br /> Yahoo! Toolbar (to save browser real estate) but still want the <br /> convenience of adding bookmarks, you can build your own JavaScript <br /> bookmarklet and add it to your browser's bookmarks toolbar to get the same <br /> one-click effect.<br /><br /><br /> 2.7.1. The Magic of Bookmarklets<br /><br /><br /> A bookmarklet is a bit of JavaScript code stored in a web browser <br /> bookmark. Bookmarklets give you a way to run code that can interact with <br /> the current page in the browser. For example, bookmarklets can change the <br /> size and colors of fonts on a page, open new browser windows, or extract <br /> information about the current page. With bookmarklets, you're in control <br /> of the script, because it runs when you click the bookmark.<br /><br /><br /> In order to implement this hack, the only thing you'll need is a browser <br /> that has bookmarks and understands JavaScript. Don't worry, that covers <br /> just about every web browser!<br /><br /><br /> 2.7.2. The Code<br /><br /><br /> Here's a look at some nicely formatted JavaScript that gets the title, <br /> URL, and selected text from the current web page at the time the <br /> bookmarklet is clicked. It then builds the proper URL for adding a Yahoo! <br /> Bookmark and opens it in a new browser window. Keep in mind that this code <br /> is nicely formatted so you can see how it operates; the functioning <br /> bookmarklet code will be formatted without linebreaks or spaces.<br /><br /><br /> // Dissected JavaScript bookmarklet for one-click Yahoo! Bookmarks<br /><br /><br /> // Set d to the document object as a shortcut<br /> var d = document;<br /><br /><br /> // Set t to the currently selected text, if available<br /> var t = d.selection?d.selection.createRange( ).text:d.getSelection( );<br /><br /><br /> // Build the URL that will add a bookmark to Yahoo! Bookmarks<br /> var url = 'http://e.my.yahoo.com/config/edit_bookmark?';<br /> url += '.src=bookmarks&';<br /> url += ' .done=http%253a%2F%2Fe.my.yahoo.com/config/set_bookmark&';<br /> url += ' .folder=1&';<br /> url += '.action=ab&';<br /> url += '.display=1&';<br /> url += '.protocol=http%3A%2F%2F&';<br /><br /><br /> // include the URL of the current page<br /> url += ' .url='+escape(d.location.href)+'&';<br /><br /><br /> // include the title of the current page<br /> url += ' .name='+escape(d.title)+'&';<br /><br /><br /> // include any selected text of the current page as a comment<br /> url += ' .comment='+escape(t)+'&';<br /> url += '.save=+Save+';<br /><br /><br /> // open a new window to add the bookmark and show the results<br /> window.open(url,<br /> '_blank',<br /> 'width=640,height=440,status=yes,resizable=yes,scrollbars=yes');<br /><br /><br /><br /><br /> Take a look at the bold querystring variables in the code. These are the <br /> primary elements of the Yahoo! URL we're concerned with. Here's a quick <br /> look at what each variable represents:<br /><br /><br /><br /><br /> .done<br /><br /><br /> The URL to display after the action is completed.<br /><br /><br /><br /><br /> .folder<br /><br /><br /> The ID of the folder in which you'd like the bookmark to be included. If <br /> you don't have multiple folders, use 1, which is the default.<br /><br /><br /><br /><br /> .url<br /><br /><br /> The URL of the site you're adding as a bookmark.<br /><br /><br /><br /><br /> .name<br /><br /><br /> The name of the site you're adding as a bookmark.<br /><br /><br /><br /><br /> .comment<br /><br /><br /> Some arbitrary text that is associated with the bookmark.<br /><br /><br /> Note also that values for these querystring variables have been escaped <br /> for use in a URLeither by hand, as in the case of .done, or with the <br /> JavaScript escape( ) function. This ensures that any characters that are <br /> illegal in URLs have been converted to their hexadecimal equivalent.<br /><br /><br /> Unfortunately, a bookmarklet is no place for readable code with comments <br /> and line breaks. Instead, the code needs to be smashed into its most <br /> compact form. Here's a look at the code reformatted for use in a <br /> bookmarklet:<br /><br /><br /> javascript:d=document;t=d.selection?d.selection.createRange( ).text:d.<br /><br /><br /><br /> getSelection( );void(window.open('http://e.my.yahoo.com/config/edit_<br /><br /><br /><br /> bookmark?.src= bookmarks&&.done=http%253a%2F%2Fe.my.yahoo.com/config/set_<br /><br /><br /><br /> bookmark&.folder=1&.action=abamp;.display=1&.protocol=http%3A%2F%2F&.<br /><br /><br /><br /> url='+escape(d.location.href)+'&.name='+escape(d.title)+'&.comment=<br /><br /><br /><br /> '+escape(t)+'&.save=+Save+','blank','width=640,height=440,status=yes,<br /><br /><br /><br /> resizable=yes,scrollbars=yes'))<br /><br /><br /><br /><br /> As you can see, it looks similar to the preceding code, but with some <br /> important changes. The javascript: at the beginning tells the browser to <br /> execute what follows as a bookmarklet rather than a standard bookmark with <br /> a URL. Also, the void( ) operator often comes in handy in bookmarklets, <br /> because it stops the expression it surrounds from returning a value. In <br /> this case, we don't really care what value is returned when the window <br /> opens; we just want the window to open, and void( ) does the trick.<br /><br /><br /> 2.7.3. Running the Hack<br /><br /><br /> The installation process for the bookmarklet will be unique to the browser <br /> you'd like to use it with. If you know how to create and edit a bookmark, <br /> you know how to install a bookmarklet. Simply create a new bookmark and <br /> add the code in place of a URL. Some browsers will warn you that <br /> javascript: is not a valid protocol, but you can ignore that message. <br /> You'll also want to give your bookmarklet a snappy, short name, such as <br /> Add Y!Bookmark, as shown in the links bar in Figure 2-16.<br /><br /><br /> Once the bookmark is in place, browse to any page, highlight some text on <br /> the page, and click away! Once you click, a new window will let you know <br /> the bookmark has been added to your list, as shown in Figure 2-17.<br /><br /><br /> From here, you can edit the newly added bookmark by clicking on the pencil <br /> icon. Simply close the window when you're finished.<br /><br /><br /><br /><br /> Yahoo! removes any apostrophes from Bookmark Comments, so <br /> you'll have to put up with misspellings here and there, <br /> especially if you're adding text that was highlighted on a web <br /> page.<br /><br /><br /><br /><br /><br /><br /><br /><br /> Figure 2-16. The Add Y!Bookmark bookmarklet in the browser toolbar<br /><br /><br /><br /><br /><br /><br /><br /> Figure 2-17. The new bookmark added to Yahoo! Bookmarks<br /><br /><br /><br /><br /><br /> The best part of keeping your bookmarks at Yahoo! is that the next time <br /> people are gathered around someone else's laptop trying to remember the <br /> location of some cool site you visited last week, you can save the day by <br /> saying, "I have that site bookmarked at Yahoo!"<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 29. Import Existing Bookmarks into Yahoo! Bookmarks<br /><br /><br /><br /><br /><br /> To consolidate or build a Bookmark library quickly, you can import <br /> existing bookmarks from applications such as Firefox, Internet Explorer, <br /> or web applications that support OPML.<br /><br /><br /> Yahoo! lets you store up to 1,000 bookmarks on their server, making them <br /> easily accessible from any computer. But transferring or creating 1,000 <br /> bookmarks by hand could take you a few months of concentrated effort and <br /> some vacation time from work. Even with one-click adding [Hack #28], <br /> you're looking at a few hours of solid clicking to even approach the <br />limit.<br /><br /><br /> Luckily, you can take advantage of the bookmarks you already have by <br /> importing them. Yahoo! provides some tools to make the process of <br /> importing bookmarks take a few minutes rather than a few months. Also, if <br /> you use other bookmark-like applications on the Web (such as Blogrolling, <br /> Bloglines, or Kinja) you can probably find a way to import them into <br /> Yahoo! Bookmarks by using exporting features those applications provide.<br /><br /><br /> Each of these hacks relies on the Import Bookmarks feature that you'll <br /> find at your Yahoo! Bookmarks (at http://bookmarks.yahoo.com/, toward the <br /> top of the page).<br /><br /><br /> 2.8.1. Internet Explorer Bookmarks<br /><br /><br /> Importing your Internet Explorer bookmarks is a fairly painless process, <br /> thanks to an ActiveX Control Yahoo! has put together that's appropriately <br /> called Yahoo! Favorites Importer. To get to the import page, click Import <br /> Bookmarks from the Yahoo! Bookmarks page and choose the Internet Explorer <br /> for Windows link.<br /><br /><br /> An ActiveX Control is a bit of code that runs in your browser and that can <br /> interact with your desktop applications. As you might guess, there are <br /> some security concerns with this type of code, so you might see a warning <br /> in your browser like the one shown in Figure 2-18.<br /><br /><br /> Go ahead and click on the yellow-highlighted area, and then choose Install <br /> ActiveX Control…. Once it's installed, click the Import Favorites button, <br /> and all of your folders and bookmarks will be added to your Yahoo! <br /> Bookmarks.<br /><br /><br /><br /><br /> Figure 2-18. Import Bookmarks ActiveX warning<br /><br /><br /><br /><br /><br /> 2.8.2. Firefox Bookmarks<br /><br /><br /> Importing Firefox or Netscape bookmarks is a two-step process. First, you <br /> need to export your Firefox bookmarks to an HTML file. From any browser <br /> window, choose Bookmarks Manage Bookmarks to bring up the Firefox bookmark <br /> manager. From there, choose File Export. The default name for the file is <br /> bookmarks.html; be sure to save it in a location you'll remember.<br /><br /><br /> Next, back at Yahoo! Bookmarks, click the Import Bookmarks link and then <br /> click Netscape (the label is a relic from the Netscape browser that <br /> Firefox grew out of). Click the Browse button at the bottom of the page, <br /> and find bookmarks.html on your local computer. Finally, click Import <br /> Bookmarks, and Yahoo! will do the heavy lifting from there. You should now <br /> find all of your bookmarks and bookmark folders in your Yahoo! Bookmarks.<br /><br /><br /> 2.8.3. OPML Applications<br /><br /><br /> Browsers aren't the only place you'll find lists of sites. With the rising <br /> popularity of web-based RSS readers and link-sharing services, many people <br /> have lists of favorite links in many different formats across the Web. <br /> Fortunately for us, an emerging standard of exchanging links between <br /> applications exists. This standard is an XML format called Outline <br /> Processor Markup Language ( OPML). OPML is used for making lists of just <br /> about anything, but it's used primarily for trading lists of links.<br /><br /><br /> Yahoo! doesn't import OPML files, so the trick to importing bookmarks <br /> stored in OPML is to convert an existing OPML file into the <br /> Firefox/Netscape bookmark format. Rogers Cadenhead ran into this same <br /> problem and created a program called the OPML Link Publisher <br /> (http://www.cadenhead.org/workbench/code/opmlLinkPublisher ). The OPML <br /> Link Publisher takes an OPML file and converts it into the proper HTML for <br /> bookmarks. With these tools, you can import bookmarks from just about <br /> anywhere.<br /><br /><br /> For example, I use the RSS reader Bloglines (http://www.bloglines.com/). <br /> This application lets me assemble a list of sites I read on a regular <br /> basis and alerts me when something new has been posted. To get an OPML <br /> list of your Bloglines sites, go to your feeds and click Edit from the top <br /> menu. Scroll past your list of feeds and choose Export Subscriptions. <br /> You'll find a list of all of your subscriptions in OPML format. Save it <br /> somewhere handy, such as your C: drive, and give it a name you'll <br /> remember, such as bloglines_export.xml.<br /><br /><br /> Because OPML is an evolving standard, you might need to massage the file a <br /> bit to turn it into a format that OPML Link Publisher expects. Though most <br /> implementations of OPML for bookmarks are similar, there are enough <br /> differences to make them seem incompatible. For example, OPML Link <br /> Publisher looks for text and url attributes in the XML, while Bloglines <br /> gives you title and htmlUrl attributes. A quick fix is to open the file in <br /> Notepad and do a global search and replace for these terms. It's a bit of <br /> a hassle, but it's far faster than building your own bookmarks file.<br /><br /><br /> Once the OPML file is ready to go, download a copy of Cadenhead's OPML <br /> Link Publisher and create the required olp.properties file in the same <br /> directory as the application. Then, edit the newfile to contain the <br /> location of your OPML file to be converted and the location of the <br /> resulting bookmarks.html file. The olp.properties file should look <br /> something like this:<br /><br /><br /> olp.mozillaUserFolder=C:/<br /> olp.bookmarkSource=C:/bloglines_export.xml<br /><br /><br /><br /><br /> With these pieces in place, you can run OPML Link Publisher from a Windows <br /> command prompt, like so:<br /><br /><br /> javajar OPMLLinkPublisher.jar<br /><br /><br /><br /><br /> If everything goes as expected, you should have a shiny new bookmarks.html <br /> file you can use to import your links at Yahoo! Bookmarks. Yahoo! never <br /> has to know the file wasn't generated by Firefox, and you get to have <br /> instant access to all of your favorite sites.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 30. Open Yahoo! Bookmarks in a Sidebar<br /><br /><br /><br /><br /><br /> The easiest way to take your Yahoo! Bookmarks out for a surfing binge is <br /> by tacking them up in a browser sidebar.<br /><br /><br /> Once you've invested the time and energy into building your Yahoo! <br /> Bookmarks collection, you'll be ready to take them for a spin. Of course, <br /> you can view them in My Yahoo!, where they're meant to be displayed, but <br /> it's also useful to bring them up in a browser sidebar for quick surfing. <br /> This saves you the trouble of opening the sites in a new window and losing <br /> your place, and it lets you focus on seeing what's new at your favorite <br /> sites.<br /><br /><br /> One problem with this plan is that you can't isolate your Yahoo! Bookmarks <br /> to their own page. They're fully integrated with the My Yahoo! page. <br /> Fortunately, Jason B. Silverstein at Yahoo! pointed out a little-known <br /> page that does isolate your Yahoo! Bookmarks into their own space: <br /> http://my.yahoo.com/tearoff/sites.html. This page is used to display <br /> bookmarks inside Yahoo! Messenger, but there's no reason you can't use it <br /> to build your own sidebar.<br /><br /><br /> To use the sidebar, you'll need to be logged in at My Yahoo!. But once <br /> that's taken care of, your new isolated Yahoo! Bookmarks will be ready to <br /> go.<br /><br /><br /> 2.9.1. A Firefox Sidebar<br /><br /><br /> The Firefox browser makes quick work of opening web pages in a sidebar. <br /> Simply navigate to the Yahoo! Bookmarks URL and choose Bookmarks Bookmark <br /> This Page… from the Firefox menu (or Ctrl-D if you're a fan of keyboard <br /> shortcuts). Then give the bookmark a descriptive name, such as Y!Bookmarks <br /> Sidebar.<br /><br /><br /> Now find your newly added bookmark, right-click, and choose Properties to <br /> bring up the bookmark's properties, as shown in Figure 2-19.<br /><br /><br /><br /><br /> Figure 2-19. Bookmark properties dialog<br /><br /><br /><br /><br /><br /> Check the "Load this bookmark in the sidebar" option, and you'll be set. <br /> Whenever you click the bookmark in the future, your Yahoo! Bookmarks will <br /> open in a sidebar. From there, you can click down the list, and the <br /> sidebar will stay put while your bookmark opens in the main window (see <br /> Figure 2-20).<br /><br /><br /> 2.9.2. An Internet Explorer Sidebar<br /><br /><br /> Setting up a custom Internet Explorer sidebar isn't quite as easy, but it <br /> is possible to customize the built-in search bar. Internet Explorer's <br /> search bar is a window that opens in a sidebar. You can activate the <br /> search bar by clicking the Search button in your main toolbar, as shown in <br /> Figure 2-21.<br /><br /><br /><br /><br /> Figure 2-20. Yahoo! Bookmarks in a Firefox sidebar<br /><br /><br /><br /><br /><br /><br /><br /> Figure 2-21. Internet Explorer's Search button<br /><br /><br /><br /><br /><br /> This brings up one of several search forms from some of the big search <br /> engines on the Web, including Yahoo!. However, you can put your isolated <br /> Yahoo! Bookmarks in this window by changing some values in the Windows <br /> Registry.<br /><br /><br /><br /><br /> The Windows Registry is a database that stores important <br /> application information. Be aware that hand-editing the <br /> Windows Registry could cause serious problems that would <br /> require you to reinstall Windows.<br /><br /><br /><br /><br /><br /><br /> 2.9.2.1. The code.<br /><br /><br /> To keep things simple, you can edit the relevant Windows Registry settings <br /> with a .reg file. Create a new file on your desktop called Y!Bookmarks.reg <br /> and add the following text:<br /><br /><br /> REGEDIT4<br /><br /><br /> [HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main]<br /> "Use Search Asst"="no"<br /> "Search Bar"="http://my.yahoo.com/tearoff/sites.html"<br /><br /><br /><br /><br /> 2.9.2.2. Running the hack.<br /><br /><br /> Save the file, double-click it, confirm the changes, and you're all set. <br /> This file will disable the default search pane and instead load your <br /> Yahoo! Bookmarks. You'll need to restart Internet Explorer if it's <br /> running. After that, clicking the Search button from now on will give you <br /> something similar to the page shown in Figure 2-22.<br /><br /><br /><br /><br /> Figure 2-22. Yahoo! Bookmarks in the IE search bar<br /><br /><br /><br /><br /><br /> 2.9.2.3. Hacking the hack.<br /><br /><br /> If you'd ever like to go back to the default search behavior, it's just <br /> another .reg file. You could call this one search_restore.reg and add the <br /> following text:<br /><br /><br /> REGEDIT4<br /><br /><br /> [HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main]<br /> "Use Search Asst"="yes"<br /> "Search Page"="http://home.microsoft.com/access/allinone.asp"<br /> "Search Bar"="http://home.microsoft.com/search/lobby/search.asp"<br /><br /><br /><br /><br /> Save the file, double-click it, and Internet Explorer should go back to <br /> the way it was.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 31. Publish Your Yahoo! Bookmarks<br /><br /><br /><br /><br /><br /> Give the gift of your accumulated links to the world by publishing your <br /> Yahoo! Bookmarks to the Web.<br /><br /><br /> Part of the fun of using the Web is being able to share where you've been <br /> with others. The fact that any web site can be connected to any other web <br /> site via a link is one of its defining features. On weblogs, a list of <br /> links to other weblogs is called a blogroll, and there's even a web <br /> service called Blogrolling.com that helps people organize and publish <br /> these lists of links. Since Yahoo! Bookmarks is basically one big link <br /> repository, you're already using it to store and organize your favorite <br /> links. The only piece missing from rolling your own blogroll or link <br /> directory is publishing your Yahoo! Bookmarks for the world to see.<br /><br /><br /> If you log in and view your Yahoo! Bookmarks at <br /> http://bookmarks.yahoo.com/, you'll notice an Export Bookmarks link toward <br /> the top of the page. This feature is primarily used for transferring <br /> bookmarks between Yahoo! and your browser. But because the Netscape <br /> bookmark format is an extension of standard HTML, you can use the export <br /> file to publish your links. To get the file, choose Export Bookmarks <br /> Netscape (for Windows) "Click here" to export it. Once you have the <br /> bookmarks.html file on your desktop, you can upload it to a web server, <br /> where anyone can view it.<br /><br /><br /> This process takes only a minute or two, but you wouldn't want to do this <br /> each time you added a bookmark, changed a bookmark, or reorganized your <br /> links. With a bit of Perl, you can automate this whole process and write <br /> some cleaner HTML in the process.<br /><br /><br /> To run this hack, you'll need a couple of nonstandard Perl modules <br /> installed: WWW::Yahoo::Login and WWW::Mechanize for logging into Yahoo! <br /> and fetching the bookmarks.html export, respectively.<br /><br /><br /> 2.10.1. The Code<br /><br /><br /> This script logs into Yahoo! and fetches your exported bookmarks. From <br /> there, it goes through the bookmarks line by line, adding folder names and <br /> links to a filename you specify in $file. Be sure to replace the $user and <br /> $pass values with your Yahoo! username and password so that the script can <br /> log in on your behalf. Create a file called getBookmarks.pl and add the <br /> following code:<br /><br /><br /> #!/usr/bin/perl<br /> # getBookmarks.pl<br /> # A script to download Yahoo! Bookmarks and format them as HTML<br /> # Usage: getBookmarks.pl<br /><br /><br /> use WWW::Yahoo::Login qw( login logout );<br /> use WWW::Mechanize;<br /> use strict;<br /><br /><br /> # Set some user variables<br /> my $user = "insert Yahoo! ID";<br /> my $pass = "insert Yahoo! Password";<br /> my $file = "links.html";<br /> my $bookmarkurl = "http://bookmarks.yahoo.com/config/";<br /> $bookmarkurl .= "export_bookmark?.commit=1";<br /><br /><br /> my $mech = WWW::Mechanize->new( );<br /><br /><br /> # Log into Yahoo!<br /> my $resp = login(<br /> mech => $mech,<br /> uri => $bookmarkurl,<br /> user => $user,<br /> pass => $pass,<br /> );<br /><br /><br /> # If login succeeded, loop through the HTML<br /> if ($resp) {<br /> print "Login ok!\n";<br /> my $bookmarks = $mech->content;<br /> my @bookmarks = split(/\n/, $bookmarks);<br /><br /><br /> # Open the output file<br /> open FILE, "> $file" or die "Can't open $file : $!";<br /><br /><br /> # Loop through the bookmarks, printing to file<br /> foreach my $line (@bookmarks) {<br /><br /><br /> # If the line is folder, print it<br /> if ($line =~ m!<H3[^>].*>(.*?) </H3>!gi) {<br /> print FILE "<div class=\"folder\">";<br /> print FILE $1;<br /> print FILE "</div>\n";<br /> }<br /><br /><br /> # If the line is a bookmark, print it<br /> if ($line =~ m!<A HREF="([^"]+)"[^>]+>(.*?)</A>!gi) {<br /> print FILE "<div class=\"link\">";<br /> print FILE "<a href=\"$1\">$2</a>";<br /> print FILE "</div>\n";<br /> }<br /> }<br /> # Close the output file<br /> close FILE;<br /> } else {<br /> warn $WWW::Yahoo::Login::ERROR;<br /> }<br /><br /><br /><br /><br /> 2.10.2. Running the Hack<br /><br /><br /> To run the code, simply call the script from a command prompt:<br /><br /><br /> perl getBookmarks.pl<br /><br /><br /><br /><br /> After the script has run, you should find a new file called links.html, <br /> full of your Yahoo! Bookmarks. Each link should be on its own line, <br /> surrounded by HTML <div> tags. This lets you create your own look and feel <br /> for the links with an external stylesheet. The folders have a CSS class of <br /> folder, and links have a CSS class of link. The file is all set for you to <br /> drop it into an existing web site as a server-side include, or with a bit <br /> more formatting it could be its own page.<br /><br /><br /> Now that this process is automated through a script, you can run it on a <br /> regular schedule to reap its benefits. Any changes you make at Yahoo! <br /> Bookmarks will be reflected on your remote site the next time this script <br /> runs; once every 24 hours should do it. In Windows, you can set it to run <br /> as a scheduled task from the Control Panel, calling Perl from the Run <br /> line, like this:<br /><br /><br /> C:\Perl\bin\perl.exe "C:\insert your location \getBookmarks.pl "<br /><br /><br /><br /><br /> And from Linux-based servers, you can set it as a cron job.<br /><br /><br /> Now that you're able to use Yahoo! as a public links manager, the process <br /> of sharing resources should be much simpler.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 32. Track the Media's Attention Span over Time<br /><br /><br /><br /><br /><br /> Visualize media trends by counting the total number of Yahoo! News <br /> mentions of a specific phrase over a series of dates.<br /><br /><br /> The nature of news is that it reports about what's new in the world each <br /> day. But in the rush to bring the latest news to the public, news <br /> organizations often have a pack mentality. The news being covered by the <br /> top media outlets this week is different from what was covered last week. <br /> And sometimes, looking at what news organizations decide to cover can be <br /> more interesting than the news itself.<br /><br /><br /> In that spirit, this hack is about tracking a topic's ebbs and flows <br /> through the news cycle. Because Yahoo! News brings together over 7,000 <br /> different news sources from around the world into one site, it's the <br /> perfect place to spot trends and track what the media is tracking. One <br /> drawback to tracking 7,000 news sources is that storage of that <br /> information becomes an issue. So Yahoo! News stores only the last 30 days' <br /> worth of articles. But in our 24-hour-a-day news world, 30 days ago can <br /> seem like ancient history.<br /><br /><br /><br /><br /> This hack was inspired by " Tracking Result Counts over Time" <br /> [Hack #63] from the first edition of Google Hacks. If you'd <br /> like to see how to implement a similar hack for Google Search <br /> results, track down a copy of the first edition of Google <br /> Hacks.<br /><br /><br /><br /><br /><br /><br /> The key to being able to track a keyword in news articles over time is <br /> being able to isolate articles by day. Luckily, the Yahoo! News advanced <br /> search interface (http://news.search.yahoo.com/news/advanced) gives the <br /> option to limit searches by time. So, if you want just the stories about <br /> Apple from March 1, 2005, the advanced search interface lets you bring <br /> them up by specifying March 1 as the start and end date. Another great <br /> feature of the advanced search interface is the ability to limit your <br /> search to a specific category. By selecting Technology in addition to <br /> specifying the date, you can be sure to weed out stories about the fruit <br /> that grows on trees and stick with stories about the company that makes <br /> computers.<br /><br /><br /> Once you isolate stories to a particular day, you can find out how many <br /> stories contained the term you're interested in on that day. For example, <br /> there were 143 technology stories that mentioned Apple on March 1, 2005, <br /> but only 115 stories mentioned Apple on March 2. At the time of this <br /> writing, the news data available at Yahoo! Search Web Services doesn't <br /> include the ability to limit requests to a specific date, so this hack <br /> uses screen scraping to gather the data.<br /><br /><br /> Screen scraping involves programmatically downloading the HTML for a web <br /> page and picking through the source to find the bits of information you're <br /> looking for. Screen scraping is a notoriously brittle process, because it <br /> relies on finding patterns within the HTML. If Yahoo! decides to change <br /> its HTML tomorrow, the code in this hack that picks up the total results <br /> for a query will fail. Even knowing this, we're interested in only one bit <br /> of data on Yahoo! News search results pages: the estimated total number of <br /> articles for our query. Figure 2-23 shows the bit we're looking for in a <br /> search for Apple stories from March 1, 2005.<br /><br /><br /> Searching through the almost 250 lines of HTML in a results page, you can <br /> pick out the total results number from this line:<br /><br /><br /> <em>Results <strong>1 - 10</strong> of about <strong>143</strong> for <br /> <strong>apple</strong>.</em><br /><br /><br /><br /><br /> Armed with the pattern to find the total results, you can assemble the <br /> code.<br /><br /><br /><br /><br /> Figure 2-23. Total results of a Yahoo! News search for "apple"<br /><br /><br /><br /><br /><br /> 2.11.1. The Code<br /><br /><br /> Though you can't limit search by date with the Yahoo! Search Web Services, <br /> this code relies on the fact that Yahoo! News search pages at the web site <br /> have stable, predictable URLs for date-specific searches. Sticking with <br /> our example, here are the relevant pieces from a URL for Apple articles <br /> from March 1:<br /><br /><br /> http://news.search.yahoo.com/news/search?va=apple&smonth=3&<br /><br /><br /><br /> sday=1&emonth=3&eday=1<br /><br /><br /><br /><br /> As you can see, the va variable holds the query, smonth and sday the start <br /> date, and emonth and eday the end date. Knowing this pattern, you can <br /> construct a query for any time period you'd like.<br /><br /><br /> You'll need a couple of modules for this hack, including LWP::Simple to <br /> fetch the Yahoo! News page, and Date::Manip to work with dates. Add the <br /> following code to a file named track_news.pl:<br /><br /><br /> #!/usr/bin/perl<br /> # track_news.pl<br /> # Builds a Yahoo! News URL for every day<br /> # between the specified start and end dates, returning<br /> # the date and estimated total results as a CSV list.<br /> # usage: track_news.pl query="{query}" start={date} end={date}<br /> # where dates are of the format: yyyy-mm-dd, e.g. 2005-03-30<br /><br /><br /> use strict;<br /> use Date::Manip; <br /> use LWP::Simple qw(!head); <br /> use CGI qw/:standard/;<br /><br /><br /> # Set your unique Yahoo! Application ID <br /> my $appID = "insert your app ID";<br /><br /><br /> # Get the query <br /> my $query = param('query');<br /><br /><br /> # Set the News category to search tech articles <br /> # Alternates: top, world, politics, entertainment, business <br /> # more at: http://news.search.yahoo.com/news/advanced <br /> my $category = "technology";<br /><br /><br /> # Regular Expression to check date validity <br /> my $date_regex = '(\d{4})-(\d{1, 2})-(\d{1, 2})';<br /><br /><br /> # Make sure all arguments are passed correctly<br /> ( param('query') and param('start') =~ /^(?:$date_regex)?$/<br /> and param('end') =~ /^(?:$date_regex)?$/ ) or <br /> die qq{usage: track_news.pl query="{query}" start={date} end={date}\n};<br /><br /><br /> # Set timezone, parse incoming dates<br /> Date_Init("TZ=PST");<br /> my $start_date = ParseDate(param('start'));<br /> my $end_date = ParseDate(param('end'));<br /><br /><br /> # Print the CSV column titles<br /> print qq{"date","count"\n};<br /><br /><br /> # Loop through the dates<br /> while ($start_date <= $end_date) { <br /> my $month = int UnixDate($start_date, "%m"); <br /> my $day = int UnixDate($start_date, "%d");<br /> my $date_f = UnixDate($start_date,"%y-%m-%d");<br /> my $total;<br /><br /><br /> # Construct a Yahoo! News URL<br /> my $news_url = "http://news.search.yahoo.com/news/search?";<br /> $news_url .= "ei=UTF-8";<br /> $news_url .= "&va=$query";<br /> $news_url .= "&cat=$category";<br /> $news_url .= "&catfilt=1";<br /> $news_url .= "&pub=1";<br /> $news_url .= "&smonth=$month";<br /> $news_url .= "&sday=$day";<br /> $news_url .= "&emonth=$month";<br /> $news_url .= "&eday=$day";<br /> # Make the request<br /> my $news_response = get($news_url);<br /><br /><br /> # Find the number of results <br /> if ($news_response =~ m!of about <strong>(.*?)</strong>!gi) {<br /> $ total = $1;<br /> } else {<br /><br /><br /> $total = 0;<br /> }<br /><br /><br /> # Print out results<br /> print<br /> '"',<br /> $date_f,<br /> qq{","$total"\n};<br /> # Add a day, and continue the loop<br /> $start_date = DateCalc($start_date, " + 1 day");<br /> }<br /><br /><br /><br /><br /> 2.11.2. Running the Hack<br /><br /><br /> Run the script from a command line, specifying the query term and dates. <br /> Here's the query for Apple news between March 1 and March 10, 2005:<br /><br /><br /> track_news.pl query="apple" start=2005-03-01 end=2005-03-10<br /><br /><br /><br /><br /> Of course, by the time you're reading this, these dates are out of the <br /> 30-day window, so you'll need to replace them with dates that fall into <br /> the range Yahoo! News can deliver.<br /><br /><br /> If you'd like to pipe the script output to a text file, simply call it <br /> like so:<br /><br /><br /> track_news.pl query="apple" start=2005-03-01 end=2005-03-10 > apple.csv<br /><br /><br /><br /><br /> The results will look like this:<br /><br /><br /> "date","count"<br /> "05-03-01","147"<br /> "05-03-02","111"<br /> "05-03-03","112"<br /> "05-03-04","173"<br /> "05-03-05","27"<br /> "05-03-06","51"<br /> "05-03-07","181"<br /> "05-03-08","171"<br /> "05-03-09","111"<br /> "05-03-10","130"<br /><br /><br /><br /><br /> Just glancing at this list, you can see that Apple media coverage started <br /> off strong, tapered off a bit, and then came back with a vengeance on <br /> March 7. It's tough to pinpoint a reason for the differences, but it might <br /> be a way to spot changes that will affect the company.<br /><br /><br /> 2.11.3. Working with the Results<br /><br /><br /> With a short list, it's easy to see where the spikes in media mentions <br /> are. But with longer lists, it might help to have a visual representation <br /> of the data. If you send the script output to a .csv file, you can simply <br /> double-click the file to open it with Excel. The chart wizard can give you <br /> a quick overview, such as the one for the entire month of March 2005 shown <br /> in Figure 2-24.<br /><br /><br /><br /><br /> Figure 2-24. Excel graph tracking tech news mentioning "apple"<br /><br /><br /><br /><br /><br /> As you can see, the mentions of Apple across technology stories in the <br /> month of March dip and peak at the beginning and end of the work week.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 33. Monitor the News with RSS<br /><br /><br /><br /><br /><br /> Keep your finger on the pulse of your favorite news topics by adding <br /> Yahoo! News search results to your favorite RSS reader.<br /><br /><br /> Trying to stay on top of all of the news on a specific topic can feel like <br /> a losing battle. Say you spend your time working with maps, so you're <br /> interested in cartography. Imagine you're interested in every aspect of <br /> cartography and want to keep up with any new mentions of the word <br /> cartography in the news. You'd like to hear about everything from new <br /> mapping applications for the Web to new geographic discoveries. This could <br /> take a lot of time and effort, subscriptions to all of the major <br /> newspapers, and the time to read every article looking for mentions of <br /> cartography. Of course, Yahoo! News pulls this information together into <br /> one web site and makes it searchable, but even that can be tedious to <br /> check on a regular basis.<br /><br /><br /> Starting at Yahoo! News, you could type the word into the form and get <br /> back some stories from the past few days. You could visit the site every <br /> day to check for new stories, but keeping track of the changes between <br /> queries each day would be a tedious task by hand. You'd have to compare <br /> the current list of stories with yesterday's list, and see what sites show <br /> up in the results that weren't there the day before. Luckily, there's an <br /> easier, automated way to monitor search results with RSS.<br /><br /><br /> Yahoo! offers RSS output of many of its features, including search <br /> results. The simple RSS format can be used to syndicate information across <br /> web sites (including services such as My Yahoo!). Web sites and programs <br /> that consume RSS are called newsreaders, and using one can dramatically <br /> increase the amount of information you can consume in a much shorter <br /> period of time. Instead of visiting a series of news sites looking for new <br /> information on topics you're interested in, you can simply subscribe to a <br /> news feed for the topic and any new information automatically appears in <br /> your newsreader.<br /><br /><br /> Yahoo! has made it painfully easy to track information from Yahoo! News in <br /> My Yahoo!. If you do a Yahoo! News search at <br /> http://news.search.yahoo.com/, you'll see an "Add to My Yahoo! / RSS" <br /> header to the right of the results, as shown in Figure 2-25.<br /><br /><br /><br /><br /> Figure 2-25. "Add to My Yahoo! / RSS" box on News search results<br /><br /><br /><br /><br /><br /> This box gives you all of the information you need to start tracking a <br /> phrase in your own newsreader. If you use My Yahoo!, you can simply click <br /> the button with the blue plus sign and you'll be reading the latest <br /> stories about your favorite topic on a regular basis (see Figure 2-26).<br /><br /><br /><br /><br /> Figure 2-26. Yahoo News! search results in My Yahoo!<br /><br /><br /><br /><br /><br /> If you use a different newsreader, you'll need to follow some quick steps. <br /> First, right-click the white-on-orange XML icon (or Ctrl-click it on a <br /> Mac) and choose Copy Link Location or Copy Shortcut, depending on your <br /> browser. This will put the feed URL for the current search results onto <br /> your virtual clipboard. Then, open your newsreader and find the dialog for <br /> adding a subscription. Copy the feed URL, and you should find a new <br /> subscription for your search, such as the one highlighted in Figure 2-27.<br /><br /><br /> Now, if any news articles that flow through one of the 7,000 sources at <br /> Yahoo News! contain the term cartography, you'll know about it as you <br /> browse your other news sources. Of course, this works just as well with <br /> other queries, and if mapping isn't your area, you can customize the feeds <br /> to track your own interests.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 34. Personalize My Yahoo!<br /><br /><br /><br /><br /><br /> My Yahoo! can be your window to the world, if you take some time to <br /> specify what you want to see and how you want to see it.<br /><br /><br /> My Yahoo! is designed to be a one-stop spot for information that's <br /> important to you. Putting together a My Yahoo! space is a bit like editing <br /> your own newspaper. You can decide which news sources you'd like to see <br /> headlines from, where each source is placed on the page, and how the page <br /> itself appears. Every good editor needs to know what's available, and this <br /> hack should provide you with the tools to build your own personalized <br /> information hub.<br /><br /><br /><br /><br /> Figure 2-27. Yahoo News! search results in NetNewsWire<br /><br /><br /><br /><br /><br /> To get started, browse to My Yahoo! (http://my.yahoo.com/) and note the <br /> controls across the top of the page, as shown in Figure 2-28.<br /><br /><br /><br /><br /> Figure 2-28. My Yahoo! controls<br /><br /><br /><br /><br /><br /> Each of these controls lets you personalize My Yahoo! in some way. Add <br /> Content lets you add information sources, Change Layout adjusts where each <br /> module is located, and Change Colors lets you specify a look and feel. <br /> With these three options, you can create a source of news and information <br /> tailored specifically for you.<br /><br /><br /> 2.13.1. Yahoo! Modules<br /><br /><br /> A My Yahoo! module is simply a box on a My Yahoo! page. Each module <br /> typically contains information from a single source, and you can specify <br /> some preferences for each module.<br /><br /><br /> Adding a module to your My Yahoo! page is simply a matter of browsing <br /> through a list of modules and clicking the Add button. Start by clicking <br /> Add Content at the top of the My Yahoo! page. From here, you can search <br /> for a specific type of content or news source, or browse lists of modules <br /> arranged by topic.<br /><br /><br /> In addition to news headlines from sources such as the New York Times or <br /> USA Today, there are a number of modules powered by Yahoo! that add extra <br /> features to the page. Some of the Yahoo! modules go beyond a list of <br /> headlines and let you tap into some features from across Yahoo! web sites. <br /> You can find them under the Yahoo! Services link, and here are just a few <br /> of the Yahoo!-powered modules available:<br /><br /><br /><br /><br /> Best Fare Tracker<br /><br /><br /> Choose a departure city and an arrival city and you can monitor low fare <br /> prices for the trip. You can add several trips to the module, so you can <br /> keep your eye on prices for different areas.<br /><br /><br /><br /><br /> Lottery Results<br /><br /><br /> Select your state and see winning lottery numbers from lotteries in your <br /> area.<br /><br /><br /><br /><br /> Package Tracker<br /><br /><br /> This module provides links to the package tracking services at Yahoo! <br /> Small Business (http://smallbusiness.yahoo.com/). To track a package, <br /> click the link for Airborne Express, Federal Express, UPS, or the U.S. <br /> Postal Service and enter a tracking number. You can also quickly look up <br /> Zip Codes by address with this module.<br /><br /><br /><br /><br /> HotJobs<br /><br /><br /> View job openings in your city for a selected industry. If you use Yahoo! <br /> HotJobs (http://hotjobs.yahoo.com/), you can also use this module to track <br /> your existing job searches and see how many people have viewed your <br />resume.<br /><br /><br /><br /><br /> Weather<br /><br /><br /> Powered by Yahoo! Weather (http://weather.yahoo.com/), this module tracks <br /> the daily high and low temperature in cities you specify, and it includes <br /> an icon that indicates whether it's a sunny, cloudy, or stormy day in that <br /> city.<br /><br /><br /><br /><br /> Stock Portfolios<br /><br /><br /> If you've created your own stock portfolios [Hack #23] at Yahoo! Finance <br /> (http://finance.yahoo.com/), you can view them with this module.<br /><br /><br /><br /><br /> Movie Showtimes<br /><br /><br /> Based on your chosen cities and favorite theaters [Hack #41] at Yahoo! <br /> Movies (http://movies.yahoo.com/), this module displays movies and their <br /> show times.<br /><br /><br /><br /><br /> TV Schedule<br /><br /><br /> This module shows what's on your channel lineup [Hack #44] at the time you <br /> specify. You can use the list of favorite channels that you set up at <br /> Yahoo! TV (http://tv.yahoo.com/), or you can see a specified number of <br /> channels.<br /><br /><br /> To add some visual interest to the page, try adding a few of the following <br /> modules that will show pictures:<br /><br /><br /><br /><br /> Comics<br /><br /><br /> This module is included by default and includes a daily comic strip or <br /> editorial cartoon. You can choose which comics you'd like to see each day <br /> by clicking the Edit link.<br /><br /><br /><br /><br /> Photos<br /><br /><br /> If you have personal photographs stored on Yahoo! Photos <br /> (http://photos.yahoo.com/), you can add this module to see a random photo <br /> from your collection. You can choose which albums you want the module to <br /> draw from and how often you want the photo to change.<br /><br /><br /><br /><br /> News<br /><br /><br /> Photos You can choose from three different Yahoo! News <br /> (http://news.yahoo.com/) photo modules: Lead Photo with a single photo and <br /> story, News Photos showing popular photos from Yahoo! News, or <br /> Entertainment Photos for celebrity watching.<br /><br /><br /> Once you've added a module to My Yahoo!, you can change the settings at <br /> any time by clicking the Edit button and then clicking Edit Content. Each <br /> Yahoo! module has its own settings page. For example, Figure 2-29 shows <br /> the page that lets you add or remove cities from the Weather module.<br /><br /><br /><br /><br /> Figure 2-29. Editing the My Yahoo! Weather module<br /><br /><br /><br /><br /><br /> You can completely remove a module from the page by clicking the box with <br /> the x in the upper-right corner of the module.<br /><br /><br /> Of course, there are many options for content beyond those powered by <br /> Yahoo!, and chances are very good that you can add modules from your <br /> favorite web sites [Hack #35] with My Yahoo!.<br /><br /><br /> 2.13.2. Layout<br /><br /><br /> There are a couple of different ways to move modules around within the <br /> page. The simplest way to move a module is to click the Edit button and <br /> from the menu choose a direction in which to move the module. You can move <br /> a module up or down or to the top or bottom within a column. Figure 2-30 <br /> shows the Edit menu for the Weather module.<br /><br /><br /><br /><br /> Figure 2-30. Moving the Weather module<br /><br /><br /><br /><br /><br /> For a more complex change in the layout, click the Change Layout link at <br /> the top of the page. From here, you can switch from the standard <br /> two-column layout to three columns and move modules up or down and between <br /> columns, as shown in Figure 2-31.<br /><br /><br /> You can also have up to six My Yahoo! pages, if you have a lot of <br /> information to track. Click the Add New Page link in the upper-right <br /> corner of the page to create a new space to work with. You can name the <br /> pages anything you'd like. Once you've created your new page, you can <br /> choose a page to view by selecting it from the page menu as shown in <br /> Figure 2-32.<br /><br /><br /><br /><br /> Figure 2-31. Layout settings page at My Yahoo!<br /><br /><br /><br /><br /><br /> Choose Add/Delete Page from the menu to organize your pages. You can <br /> rename them, remove them, set a default page, or change the refresh rates <br /> for the pages.<br /><br /><br /> 2.13.3. Colors<br /><br /><br /> With modules and the layout tailored to your taste, the only piece left is <br /> the look and feel. Click the Change Colors link at the top of the page to <br /> browse through existing themes for My Yahoo! pages. The themes range from <br /> subtle to gaudy, and you'll have to browse around to find one you like.<br /><br /><br /><br /><br /> If you ever change themes to something that makes your eyes <br /> bleed and you just want to get back to something readable, <br /> choose the Yahoo! category from the Theme Directory and look <br /> for My Yahoo! Basic. Click "Use this theme," and you'll go <br /> back to the default highly readable (though bland) theme.<br /><br /><br /><br /><br /><br /><br /> If none of the themes quite fit the bill, you can always edit the theme <br /> colors by hand. On the left side of the page, you'll find a Customize <br /> Theme link that leads to the color editor. As you choose colors for parts <br /> of the My Yahoo! page, you can see the changes reflected in the preview in <br /> the bottom frame, as shown in Figure 2-33.<br /><br /><br /><br /><br /> Figure 2-32. Choosing a My Yahoo! page<br /><br /><br /><br /><br /><br /> You can also choose between a half-dozen different fonts for the text on <br /> the page and increase or decrease the font size. You won't be able to add <br /> your own background graphics or logos to the page, but you can alter the <br /> colors for almost every element on the page.<br /><br /><br /> Once you've taken the time to customize My Yahoo! by adding modules, <br /> adjusting the layout, and changing the colors, you'll find that it feels <br /> much more like your own space, with quick access to the information you <br /> want.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 35. Track Your Favorite Sites with RSS<br /><br /><br /><br /><br /><br /> One of the most powerful features of My Yahoo! allows you to add RSS feeds <br /> from any online information source.<br /><br /><br /> My Yahoo! offers easy access to national and international news. With a <br /> few clicks, you can add the top headlines from national news services, <br /> such as Reuters, the Associated Press, or USA Today. But the real power of <br /> My Yahoo! is not only that it gives you access to these great sources, but <br /> also that it lets you add any news source to your daily read. The key to <br /> this flexibility is My Yahoo!'s ability to read RSS.<br /><br /><br /><br /><br /> Figure 2-33. Editing theme colors at My Yahoo!<br /><br /><br /><br /><br /><br /> RSS stands for "really simple syndication" or "rich site summary," <br /> depending on who you ask. What's important is that RSS is a standard XML <br /> format for sharing headlines and news summaries across web sites. Just as <br /> a web page is formatted for display in a web browser, RSS feeds are <br /> formatted for display in newsreaders like My Yahoo!.<br /><br /><br /> Everyone from an individual in his basement writing a weblog to a large <br /> media giant like the New York Times can publish RSS to be used with <br /> services such as My Yahoo! Knowing this allows you to bring in more news <br /> sources than the standard choices Yahoo! provides automatically.<br /><br /><br /> 2.14.1. Finding RSS Feeds<br /><br /><br /> Keep in mind that not every news source out there has an RSS feed. And <br /> those that do don't always make the RSS feed easy to find. Part of the <br /> skill of adding content to My Yahoo! is being able to find the RSS feeds <br /> you care about. The key to the process is finding the feed URL so you can <br /> copy and paste it into a form at My Yahoo!. Like an address on a house, a <br /> feed URL tells services like My Yahoo! where to find updated information. <br /> Here are some tips for spotting feed URLs.<br /><br /><br /> 2.14.1.1. Go to the source.<br /><br /><br /> The first place to look for feed URLs is at your favorite web sites. Most <br /> sites that offer an RSS feed will have an orange image with white letters <br /> that say " XML" or "Finding RSS Feeds." Figure 2-34 shows a number of <br /> variations you might see on the front page of a web site.<br /><br /><br /><br /><br /> Figure 2-34. Variations on the white-on-orange XML theme<br /><br /><br /><br /><br /><br /> Nine times out of ten, this image will link to site's feed URL<br /><br /><br /><br /><br /> Remember that RSS is an XML format, which is why the terms are <br /> used interchangeably in the images.<br /><br /><br /><br /><br /><br /><br /> To copy the feed URL, right-click the icon and choose Copy Link Location <br /> (or Copy Shortcut in Internet Explorer) from the menu. At this point, the <br /> feed URL will be available on your virtual clipboard, ready to paste into <br /> My Yahoo!<br /><br /><br /> 2.14.1.2. Look for auto-discovery.<br /><br /><br /> Even sites that don't include an orange-and-white XML icon might leave <br /> clues about the RSS feed URL in their source HTML. To solve the problem of <br /> finding feeds, a standard called RSS auto-discovery has emerged. Sites <br /> that want to make it easy for people to find their feed URL can include a <br /> special HTML tag in the source of their pages to let applications such as <br /> web browsers find their feed URL. Once browsers are "aware" of <br /> auto-discovery and looking for the auto-discovery tag, they can let the <br /> user know when they've spotted an RSS feed URL in a web page. Firefox lets <br /> users know by displaying an orange icon in the lower-right corner of the <br /> browser window, as shown in Figure 2-35.<br /><br /><br /> Even though SFgate.com doesn't have an orange XML icon or a link to its <br /> RSS feed on the home page, once you spot this orange RSS feed indicator, <br /> you can use Firefox's View Source feature to find the auto-discovery HTML <br /> tag that holds the feed URL. To view the source of any web page, choose <br /> View Page Source from the browser's top menu. Finding the tag can be <br /> tricky, but it is always located toward the top of the HTML page, between <br /> the opening <head> and closing </head> tags. For example, the SFGate.com <br /> page in Figure 2-35 has the following auto-discovery tag in its HTML <br /> source:<br /><br /><br /> <link href="http://www.sfgate.com/rss/feeds/news.xml" rel="alternate"<br /> type="application/rss+xml" title="SFGate: Top News Stories" /><br /><br /><br /><br /><br /> Note the URL contained in the HRef element. This is the site's RSS feed <br /> URL, ready for copying and pasting into My Yahoo!.<br /><br /><br /> Like Firefox, the Yahoo! Toolbar is also smart enough to recognize this <br /> tag in pages you visit. If you have the toolbar installed and browse a <br /> site with the RSS auto-discovery tag, you'll find that a blue "Add to My <br /> Yahoo!" button with a plus signlike the one shown in Figure 2-36will <br /> appear on the toolbar.<br /><br /><br /> Instead of rooting around in a site's HTML to find the URL, you'll be able <br /> to simply click the button to add the site to your list of news sources.<br /><br /><br /><br /><br /> Figure 2-35. Firefox with the orange RSS feed indicator in the lower-right <br /> corner<br /><br /><br /><br /><br /><br /><br /><br /> Figure 2-36. The Yahoo! toolbar with a blue "Add to My Yahoo!" button<br /><br /><br /><br /><br /><br /> 2.14.2. Adding to My Yahoo!<br /><br /><br /> Once you have the feed URL of the news source copied to your virtual <br /> clipboard, head to My Yahoo! and log in. From there, click the Add Content <br /> link toward the top of the page. On the Add Content page, click the "Add <br /> RSS by URL" link shown in Figure 2-37.<br /><br /><br /> The RSS Add page contains a single form field, where you can paste the <br /> feed URL you've been saving in your clipboard with Ctrl-V. Clicking Add <br /> will let you preview the feed so that you can make sure it's what you <br /> want. Figure 2-38 shows the SFGate.com feed preview.<br /><br /><br /> If you compare the preview in Figure 2-38 with the web page in Figure <br /> 2-35, you'll see that the headlines are the same. And finally, the Add <br /> button with the blue plus sign will finish the work of adding the feed. <br /> From that point on, you'll find the news source on your My Yahoo! page, as <br /> shown in Figure 2-39.<br /><br /><br /><br /><br /> Figure 2-37. "Add RSS by URL" link at My Yahoo!<br /><br /><br /><br /><br /><br /><br /><br /> Figure 2-38. SFGate.com RSS feed preview at My Yahoo!<br /><br /><br /><br /><br /><br /><br /><br /> Figure 2-39. SFGate.com in My Yahoo!<br /><br /><br /><br /><br /><br /> Now that you know the complex way to add outside sources to My Yahoo!, <br /> you'll be happy to know there's an easier way. The entire copy and paste <br /> process can be shortened to one click at sites that support the " Add to <br /> My Yahoo!" button shown in Figure 2-40.<br /><br /><br /><br /><br /> Figure 2-40. The "Add to My Yahoo!" button found at some sites<br /><br /><br /><br /><br /><br /> Not every site with an RSS feed includes the "Add to My Yahoo!" button, <br /> but as RSS feeds become more and more popularand as My Yahoo! becomes <br /> known as a place to consume RSSyou might see it popping up at more of the <br /> sites you visit. When you spot one, click it, and you'll go directly to <br /> the preview page for that feed at My Yahoo!<br /><br /><br /> Taking the time to add your favorite sites to My Yahoo! will let you keep <br /> up with many more sites than you'd be able to by visiting each site <br /> individually. Not only will you be reading information that's more <br /> relevant to you, you'll be reading it more efficientlywhen it's updated, <br /> and alongside the rest of your favorites.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 36. Add a Feed to My Yahoo! with a Right-Click<br /><br /><br /><br /><br /><br /> Speed up the time it takes to add RSS feeds to My Yahoo! with Internet <br /> Explorer.<br /><br /><br /> Adding an RSS feed to My Yahoo! isn't a complex process, but it does <br /> involve some copying, pasting, clicking, and generally breaking out of the <br /> flow of reading a site. With a bit of browser hacking, you can reduce the <br /> friction of adding sites to My Yahoo! by adding a context menu entry.<br /><br /><br /> A context menu is the menu that pops up when you right-click an element on <br /> a web page (or Ctrl-click it on a Mac). The context part of its name <br /> refers to the fact that different choices appear in different situations. <br /> For example, when you right-click a link, you have the options to "Open <br /> Link in New Window," Copy Link Location, Bookmark This Link, and others. <br /> In another context, such as when clicking an image or clicking highlighted <br /> text, you have different choices in the menu.<br /><br /><br /> If you've been reading personal weblogs for a while, you've probably seen <br /> many variations of the white-on-orange XML buttons that indicate a link to <br /> an RSS feed, and if not you can find some examples [Hack #35] in this <br />book.<br /><br /><br /> Wouldn't it be great if you could right-click one of these buttons and <br /> have the option to "Add to My Yahoo!"? That would save you quite a few <br /> steps, and you wouldn't have to break from the site you're currently <br /> reading to add the feed. This hack shows how to add this context menu <br /> entry in Internet Explorer.<br /><br /><br /> 2.15.1. The Code<br /><br /><br /> Much like a bookmarklet [Hack #28], any JavaScript that runs via a context <br /> menu entry has access to the page currently loaded in the browser. That <br /> means that when you click the context menu entry you've added, the browser <br /> executes a script that takes some action using information from the <br /> current page.<br /><br /><br /> In this case, the action is grabbing the URL linked from the currently <br /> clicked image, constructing a special My Yahoo! URL that includes the feed <br /> URL, and opening the new URL in a new browser window.<br /><br /><br /> Save the following code to a file called AddToMyYahoo.html:<br /><br /><br /> <script language="JavaScript"><br /> var addURL = new String("http://add.my.yahoo.com/rss?url=");<br /><br /><br /> var w = window.external.menuArguments<br /> var url = w.event.srcElement.parentElement.href;<br /><br /><br /> window.open(addURL + url,null,<br /> "height=455, width=788, status=yes, scrollbars=yes, resizable=yes");<br /> </script><br /><br /><br /><br /><br /> The external.menuArguments object holds information about the current <br /> document, and the event.srcElement is the document item the user clicked. <br /> Grabbing the HRef attribute of the element's parent will give you the link <br /> URL that is around the image tag. Save the file in a spot you'll remember. <br /> For simplicity in this hack, save it to a directory called c:\scripts\.<br /><br /><br /> Now that the script is ready to go, you just need to add the context menu <br /> entry to Internet Explorer and tell it to run this particular script when <br /> you click the entry. You'll accomplish this through the Windows Registry. <br /> The Registry is a system database that holds information about <br /> applications, including Internet Explorer. You can safely make additions <br /> to the Registry via .reg files. Create a new text file called <br /> AddYahooContext.reg and add the following code:<br /><br /><br /> Windows Registry Editor Version 5.00<br /> [HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\Add to My <br /><br /><br /><br /> Yahoo!]<br /> @="c:\\scripts\\AddToMyYahoo.html"<br /> "contexts"=dword:00000002<br /><br /><br /><br /><br /><br /><br /> Backslashes, such as those in filesystem paths, must be <br /> escaped as double slashes (\\) in Registry entry files.<br /><br /><br /><br /><br /><br /><br /> Note that the contexts entry here ends with 2, which means the entry will <br /> appear only when the user has clicked an image. Other values you could use <br /> here include 1 (for anywhere), 20 (for text links), or 10 (for text <br /> selections).<br /><br /><br /> Save the file, double-click it, and confirm that you want to add the new <br /> Registry information. You'll now have a right-click menu entry called "Add <br /> to My Yahoo!" whenever you right-click an image.<br /><br /><br /> 2.15.2. Running the Hack<br /><br /><br /> Once the code and Registry settings are in place, restart Internet <br /> Explorer. Browse to a site with a feed URL link and take the new context <br /> menu entry for a spin. When you right-click an image, you should see "Add <br /> to My Yahoo!," as shown in Figure 2-41.<br /><br /><br /> When you click the "Add to My Yahoo!" menu entry, a window like the one <br /> shown in Figure 2-42 should appear with the My Yahoo! feed preview page.<br /><br /><br /> Keep in mind that the "Add to My Yahoo!" context menu entry will be <br /> available for every image on a web page, regardless of whether or not it <br /> links to an RSS feed. So you'll have to use your best judgment about when <br /> to use the feature. If the image turns out not to be linked to an RSS <br /> feed, the Yahoo! feed preview page will let you know quickly. If you don't <br /> see posts in the preview box on the right side of the page, you'll know <br /> that a feed won't be added to My Yahoo! if you click the Add button.<br /><br /><br /><br /><br /> Figure 2-41. "Add to My Yahoo!" context menu entry<br /><br /><br /><br /><br /><br /> Once you're finished adding the feed, you can simply close the pop-up <br /> window and go back to reading the site.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 37. Build Your Own News Crawler<br /><br /><br /><br /><br /><br /> The My Yahoo! Ticker can provide a nonstop stream of news, weather, and <br /> stock quotes in your Windows toolbar.<br /><br /><br /> When you watch any of the 24-hour news channels such as CNN or MSNBC, you <br /> see the ever-present crawling news ticker running along the bottom of the <br /> screen. While the news anchor reads a story about the latest celebrity <br /> court case or natural disaster, you can read completely unrelated <br /> information in the news crawler about other stories that are breaking. On <br /> the financial news channels, the news crawler across the bottom gives <br /> stock quote information that lets you keep up with how the market is <br /> faring.<br /><br /><br /><br /><br /> Figure 2-42. "Add to My Yahoo!" preview page in new window<br /><br /><br /><br /><br /><br /> Thanks to the My Yahoo! Ticker (in beta testing at the time of this <br /> writing), you can create your own endlessly crawling news ticker in your <br /> Windows taskbar that will keep you up to date with headlines, stock <br /> quotes, and weather while you're working.<br /><br /><br /> 2.16.1. Installing the Ticker<br /><br /><br /> To use the ticker, you'll need Windows 98 or higher and a recent version <br /> of Internet Explorer. If you meet these requirements, browse to <br /> http://ticker.yahoo.com/ and click the Download button. Follow the <br /> installation instructions and enable the toolbar by clicking an empty area <br /> in your Windows taskbar and choosing Toolbars My Yahoo! Ticker Beta, as <br /> shown in Figure 2-43.<br /><br /><br /> Once enabled, the ticker will add a scrolling list of stock quotes, <br /> weather, and news headlines on the right side of your Windows taskbar, <br /> similar to those shown in Figure 2-44.<br /><br /><br /><br /><br /> Figure 2-43. Enabling the My Yahoo! Ticker toolbar<br /><br /><br /><br /><br /><br /><br /><br /> Figure 2-44. My Yahoo! Ticker showing news headlines<br /><br /><br /><br /><br /><br /> You could use the ticker like this without changing any of the settings, <br /> but making the ticker your own means you'll get more relevant news and <br /> stock quotes.<br /><br /><br /> 2.16.2. Personalizing the Ticker<br /><br /><br /> To edit your ticker preferences, click the small down arrow at the far <br /> right of the ticker and then click the top choice, My Yahoo! Ticker Beta <br /> Preferences. You should see a preferences window like the one shown in <br /> Figure 2-45.<br /><br /><br /><br /><br /> Figure 2-45. My Yahoo! Ticker preferences<br /><br /><br /><br /><br /><br /> If you already have a set of customized news sources set up at My Yahoo! <br /> [Hack #34], you can enter your Yahoo! ID and password to show your My <br /> Yahoo! news sources in the ticker. Once you are logged in, any Yahoo! <br /> modules or RSS feeds you've added to My Yahoo! will scroll through the <br /> ticker.<br /><br /><br /> Alternately, you can choose the "Use as Guest" option and click the Edit <br /> News and Edit Stocks buttons to set up your ticker information. Even if <br /> you have a My Yahoo! page, you might want to see different news sources <br /> scrolling by, and the Guest account will do the trick.<br /><br /><br /> Clicking the Edit News button will give you the preferences window, as <br /> shown in Figure 2-46.<br /><br /><br /><br /><br /> Figure 2-46. My Yahoo! Ticker Guest News preferences<br /><br /><br /><br /><br /><br /> You can choose from a number of news categories and set specific colors <br /> for each. You can also set some specific Zip Codes for weather <br /> information. Clicking Edit Stocks will take you to a similar preferences <br /> window, where you can enter a number of stock symbols to watch throughout <br /> the day. They'll scroll by in your ticker, as shown in Figure 2-47.<br /><br /><br /><br /><br /> Figure 2-47. Stock symbols in My Yahoo! Ticker<br /><br /><br /><br /><br /><br /> 2.16.3. Using the Ticker<br /><br /><br /> As information crawls by, you can stop the ticker or move it backward and <br /> forward by clicking and dragging with your mouse. You can also click any <br /> headline to read the full story in your web browser, or click any stock <br /> quote to see that stock's detail page at Yahoo! Finance.<br /><br /><br /> Clicking the Y! icon on the right side of the ticker turns the ticker into <br /> a Yahoo! search form. You can enter any search query into the field, click <br /> Enter, and the results for the query will appear in a special browser <br /> window. If you'd rather see queries and links in your default web browser, <br /> you can check the Default Browser option in the Search tab of the ticker <br /> preferences. To get back to the crawling ticker at any point, click the <br /> newspaper icon on the left side of the taskbar.<br /><br /><br /><br /><br /> If you ever feel you're cramped for space in your Windows <br /> taskbar, right-click the newspaper icon to minimize the My <br /> Yahoo! Ticker. And if you want more space for the ticker, grab <br /> the bar to the left of the newspaper icon and pull down. This <br /> will put the My Yahoo! Ticker on its own row of your taskbar, <br /> stretching the full width of your screen.<br /><br /><br /><br /><br /><br /><br /> You can also navigate to a number of different Yahoo! properties with the <br /> ticker by clicking the arrow at the far right to bring up a menu like the <br /> one shown in Figure 2-48.<br /><br /><br /><br /><br /> Figure 2-48. My Yahoo! Ticker menu<br /><br /><br /><br /><br /><br /> The menu has links to a dozen different Yahoo! properties, including <br /> Yahoo! Maps, a dictionary at Yahoo! Reference, and showtimes from Yahoo! <br /> Movies. You can also click Refresh My Yahoo! Ticker Beta Now to get the <br /> latest news and headlines.<br /><br /><br /> The My Yahoo! Ticker is simple to set up and customize, and with a little <br /> work, you can create a news crawler to rival CNN's.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 38. Replace Your Phone Book with Yahoo!<br /><br /><br /><br /><br /><br /> Throw out the giant book of numbers, and find everything from business <br /> information to personal phone numbers by searching at Yahoo!.<br /><br /><br /> In the days before the Web, the local telephone directory was probably the <br /> most used book in the house. Getting in touch with friends, finding a <br /> place for dinner, and reaching local government agencies was accomplished <br /> by flipping through the pages of your phone book. Even the maps printed in <br /> the book could help you locate hard-to-find addresses.<br /><br /><br /> Now, every home that has an Internet connection can get the same local <br /> information with Yahoo!. And with Yahoo!, you not only have access to <br /> local listings and business, but you are also able to browse virtually <br /> every phone book from every city across the United States.<br /><br /><br /> 2.17.1. Finding Businesses<br /><br /><br /> Finding a business address and phone number on Yahoo! is similar to <br /> finding the information in a traditional phone book. Say you want to get a <br /> haircut in Sebastopol, California. You'd find a local directory, flip <br /> through the Yellow Pages until you find the Barbers categoryor maybe <br /> Salon, Hairdresser, or Hair Stylistand look through the listings.<br /><br /><br /> On the Web, you can browse to http://local.yahoo.com/ and type in barbers <br /> and a locationin this case, 1005 Gravenstein Hwy N Sebastopol, CA. Yahoo! <br /> will come back with a list of phone numbers and addresses, as shown in <br /> Figure 2-49.<br /><br /><br /><br /><br /> Figure 2-49. Yahoo! Local results for "barbers" near a Sebastopol, <br /> California, address<br /><br /><br /><br /><br /><br /> The listing of phone numbers and addresses is where the similarity with <br /> the phone book ends. In addition to the standard listings, Yahoo! offers <br /> many improvements that the phone book can't compete with.<br /><br /><br /> 2.17.1.1. Mapping and directions.<br /><br /><br /> Depending on how specific your initial query is, Yahoo! can know something <br /> about you the phone book could never know: your exact location. Then along <br /> with the phone and address, Yahoo! provides a distance to your location. <br /> And if you provide an exact address with your querysay, 1005 Gravenstein <br /> Highway North, Sebastopol, CAYahoo! can sort the entries by how far away <br /> they are, giving you a good guess at how long it would take you to get <br /> there.<br /><br /><br /> This knowledge of geography also lets Yahoo! show the results of any <br /> search on a map. Click the View Results on Map button at the top of any <br /> search results page to see each entry in relation to your current location <br /> and in relation to the other entries, as shown with the barbershops in <br /> Figure 2-50.<br /><br /><br /><br /><br /> Figure 2-50. Yahoo! Local results for barbershops in Sebastopol, <br /> California, plotted on a map<br /><br /><br /><br /><br /><br /> The star in the center of the map represents your current location, and <br /> each numbered square is an entry from the results page. You can click any <br /> of the squares or the titles on the right side of the page to see more <br /> information about that particular business.<br /><br /><br /> Yahoo! can also give you detailed directions to any business in the <br /> results. Click Drive To next to any entry on the results page, and you'll <br /> be asked to verify the start address and destination. From here, click Get <br /> Directions to display a map like the one shown in Figure 2-51, with a <br /> highlighted route and detailed information about where to turn along the <br /> way.<br /><br /><br /><br /><br /> Figure 2-51. Yahoo! Local directions to a barbershop in Sebastopol, <br /> California<br /><br /><br /><br /><br /><br /> From here, you have the option to print the directions so you can take <br /> them with you, email them to someone else, or send them to your cell <br />phone.<br /><br /><br /> 2.17.1.2. Sending to cell phone.<br /><br /><br /> Where a pencil and paper might have once been used to jot down an address <br /> from the phone book, you can now use the multi million dollar wireless <br /> networks all around us to send detailed information from Yahoo! Local to a <br /> mobile device. When you click "Send to Phone" next to any entry on a <br /> Yahoo! Local search results page, you'll see a form into which you can <br /> type a cell phone number. You can also check the "Add link to map and <br /> driving directions" option. When you click Send, Yahoo! sends an SMS ( <br /> Short Message Service) message to the number. SMS is a protocol cell <br /> phones use to send and receive text messages.<br /><br /><br /> The SMS message will contain the name, address, and phone number of the <br /> business. Many phones let users highlight the number so they can simply <br /> click a button to call the business. Optionally, the SMS message can <br /> include a link to a map or driving directions to the business. As with <br /> phone numbers, many phones allow you to highlight the link and bring up a <br /> smaller version of the map you'd see on the Yahoo! web site.<br /><br /><br /> 2.17.1.3. Ratings.<br /><br /><br /> Another insight the standard phone book can't provide is how other users <br /> of the phone book feel about a particular business. Yahoo! lets any user <br /> rate any business in its listing on a scale from one to five stars. If you <br /> feel like you need to voice more than a rating, you can also add a review <br /> of the business. You can browse ratings and reviews for any business by <br /> clicking the business name in the search results. The business detail page <br /> contains the average rating by Yahoo! users and links to any reviews that <br /> have been added.<br /><br /><br /> 2.17.2. Finding People<br /><br /><br /> Yahoo! provides a service called Yahoo! People Search <br /> (http://people.yahoo.com/) for finding residential phone numbers. You can <br /> search for phone numbers by name and city, or for email addresses by name. <br /> The difference between the Yahoo! People Search and your local phone book <br /> is scale: you can use Yahoo! to search across the United States. Try <br /> searching for just your last name, leaving the city blank and Entire USA <br /> (the default) selected for the state. The list might include some <br /> long-lost relatives.<br /><br /><br /> In addition to the name, address, and telephone number, each entry <br /> includes shortcuts to add the address to your Yahoo! Address Book or show <br /> the address on a map.<br /><br /><br /><br /><br /> Look carefully on results pages for boxes or columns labeled <br /> ADVERTISEMENT or Sponsored Results. Even though you might see <br /> what look like official Yahoo! links, be aware that any site <br /> within one of these boxes or columns will take you to another <br /> domain that Yahoo! doesn't control.<br /><br /><br /><br /><br /><br /><br /> If you find your own information listed in Yahoo! People Search and you'd <br /> rather not be included, you can request to be removed. To remove your <br /> email address, go to http://people.yahoo.com/py/psEmailSupp.py and enter <br /> your name and email address. Yahoo! will remove the listing within five <br /> days. To remove your address and phone listing, go to <br /> http://people.yahoo.com/py/psPhoneSupp.py and enter your information.<br /><br /><br /> Keep in mind that filling out these forms removes your information only <br /> from the Yahoo! People Search database; you'll need to contact your phone <br /> company and any other services to keep your information out of other <br /> directories. The data for the Yahoo! People Search is supplied by a <br /> company called Acxiom, and you might want to read their privacy policy and <br /> opt-out provisions at <br /> http://www.acxiom.com/default.aspx?ID=1671&DisplayID=18.<br /><br /><br /> While you won't be able to use Yahoo! Local or Yahoo! People Search as a <br /> booster seat for your toddler, the added features and convenience will let <br /> you finally say goodbye to your old phone book.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 39. Monitor Your Commute<br /><br /><br /><br /><br /><br /> Let Yahoo! Local point out construction, accidents, and other potential <br /> slow spots on your route.<br /><br /><br /> If you've ever been stuck in an inexplicable traffic jam, you know how <br /> important information can be. Just knowing the reason behind a slowdown <br /> can help you estimate how much longer you'll be stuck and make some sense <br /> of the sea of cars surrounding you. With a little planning and research, <br /> you might be able to avoid those trouble spots entirely.<br /><br /><br /> 2.18.1. Scout Your Route<br /><br /><br /> To get a general sense of traffic in your area before you leave the house, <br /> try looking up your city at Yahoo! Maps. Browse to <br /> http://maps.yahoo.com/traffic and plug in your city. You'll see a map that <br /> includes any known construction areas and traffic incidents, along with <br /> the general speed of the routes. Figure 2-52 shows the traffic around San <br /> Francisco and southern Marin County.<br /><br /><br /><br /><br /> Figure 2-52. San Francisco Bay area traffic<br /><br /><br /><br /><br /><br /> The squares on the map indicate areas with construction and triangles with <br /> exclamation points indicate a traffic incident. You can get more detail by <br /> hovering over these icons. Clicking the icon gives you even more <br /> information, as shown in Figure 2-53.<br /><br /><br /><br /><br /> Figure 2-53. Traffic incident detail<br /><br /><br /><br /><br /><br /> As you can see from Figure 2-53, the information won't always tell you <br /> when an incident will be over, but at least you'll know that the route <br /> could be slow.<br /><br /><br /> In addition to the general overview of your city, you can look for <br /> problems along a specific route. Any driving directions provided by Yahoo! <br /> Maps also include traffic information. Point your browser to <br /> http://maps.yahoo.com/, click Driving Directions (toward the top of the <br /> page), and enter a starting and ending location. The map you get by <br /> clicking Get Directions will show you traffic incidents along the route. <br /> This is great for routes you might not be familiar with, but if you have a <br /> regular commute, there are a few other ways to work this information into <br /> your daily routine.<br /><br /><br /> 2.18.2. Add Incidents to Your Dashboard<br /><br /><br /> If you're a commuter, you probably know your route by heart and won't need <br /> the map. Instead, you'll want the traffic incident information in a handy <br /> spot, such as your dashboardthat is, your Mac OS X Dashboard. In Mac OS X <br /> Tiger (Version 10.4), Apple introduced a feature called Dashboard, which <br /> contains a series of widgets that can provide information or control <br /> applications.<br /><br /><br /> The Yahoo! Local Traffic widget for Dashboard lets you specify a city, <br /> state, or Zip Code and receive traffic incidents within a radius of 4, 10, <br /> or 40 miles from the center of the area. You can also set the severity <br /> threshold to Minor, Moderate, or Major to filter out smaller incidents. <br /> Figure 2-54 shows the widget with traffic data for San Francisco.<br /><br /><br /> Clicking on any of these incidents will open a web browser to a page that <br /> shows the incident on a map at Yahoo! Maps. You can change the location or <br /> other settings by clicking the i icon in the upper-right corner. You can <br /> also run multiple instances of the widget to track several locations.<br /><br /><br /><br /><br /> Figure 2-54. Yahoo! Local Traffic widget for Mac OS X<br /><br /><br /><br /><br /><br /> To install the Yahoo! Local Traffic widget, go to <br /> http://www.apple.com/downloads/dashboard/transportation/yahoolocaltraffic.html <br /> and click Download. Double-click the .zip file to decompress it and then <br /> open the file YahooTraffic.wdgt to add the widget to your Dashboard.<br /><br /><br /> 2.18.3. Subscribe to Your Commute<br /><br /><br /> Dashboard is great for Tiger users, but if you're on Windows (or if you're <br /> a Mac user who simply hasn't upgraded yet), there's still a way to <br /> subscribe to information about your commute with RSS.<br /><br /><br /> Studying the data behind the Yahoo! Local Traffic widget, intrepid <br /> developer John Resig found that the widget was getting its data from <br /> Yahoo! in the popular RSS format; he posted his findings to his web site: <br /> http://ejohn.org/blog/traffic-conditions-data. This means you can create <br /> your own specially formatted URL to create an RSS feed of traffic <br /> incidents in your area.<br /><br /><br /> Here's a look at the format of the URL:<br /><br /><br /> http://maps.yahoo.com/traffic.rss? csz=94101& mag=4& minsev=2<br /><br /><br /><br /><br /> The three variables correspond to the preferences you can set in the <br /> dashboard widget:<br /><br /><br /><br /><br /> csz<br /><br /><br /> The Zip Code, city, or state.<br /><br /><br /><br /><br /> mag<br /><br /><br /> The magnification of the areathat is, the radius of traffic data from the <br /> center of the specified location. Possible values are 3, 4,or 5, which <br /> correspond to 4 miles, 10 miles, and 40 miles respectively.<br /><br /><br /><br /><br /> minsev<br /><br /><br /> The minimum severity that should be shown in the feed. A value of 1 sets <br /> the minimum to Minor, 2 is Moderate, and 3 is Major.<br /><br /><br /> So, putting all of the variables together, you can set a feed of moderate <br /> traffic incidents within 40 miles of San Francisco, like so:<br /><br /><br /> http://maps.yahoo.com/traffic.rss?csz=94101&mag=5&minsev=2<br /><br /><br /><br /><br /> Now you can add this URL to your favorite RSS newsreader to keep up with <br /> any traffic problems in the area. This also means you can add the data to <br /> My Yahoo! by visiting http://my.yahoo.com/ and choosing Add Content from <br /> the top of the page. Then click "Add RSS by URL" and plug in your newly <br /> created traffic feed. You'll find the new module on your My Yahoo! page, <br /> as shown in Figure 2-55.<br /><br /><br /><br /><br /> Figure 2-55. Yahoo! Traffic data in My Yahoo!<br /><br /><br /><br /><br /><br /> Another nice feature is that once this traffic data is available in My <br /> Yahoo!, you can view these incidents with your cell phone's browser. So, <br /> not only will you be able to check your commute from home or office, but <br /> you'll also have something to check when you're stuck in your car dealing <br /> with one of these incidents!<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 40. Get the Facts at Yahoo! Reference<br /><br /><br /><br /><br /><br /> Yahoo! has collected several reference books into one site for easy <br /> research and fact-checking.<br /><br /><br /> The Yahoo! Education site (http://education.yahoo.com/) contains <br /> information about schools of every level across the United States. You can <br /> look up local elementary and high schools, read reviews by parents and <br /> students, or find degree programs at universities. As part of the mix, <br /> Yahoo! has put together a collection of publicly available reference <br /> sources called Yahoo! Research to help students with their own research.<br /><br /><br /> Yahoo! Reference is available directly at http://reference.yahoo.com/, or <br /> by typing reference! into any Yahoo! search form. At this site, you'll <br /> find a collection of reference books, from a dictionary and thesaurus to <br /> classics such as Bartlett's Familiar Quotations and The Columbia <br /> Encyclopedia. Yahoo! makes these books available online for free, saving <br /> you the cost of purchasing each of these books yourself. But be aware that <br /> Yahoo! includes advertising on each page. Luckily, the advertising is <br /> clearly marked with the word Advertising, so you won't confuse a <br /> Shakespeare sonnet with an ad for The Gap.<br /><br /><br /> 2.19.1. The Collection<br /><br /><br /> Yahoo! Reference provides a single entry point for a collection of <br /> publicly available resources. Here's a look at the reference sources <br /> available:<br /><br /><br /><br /><br /> The American Heritage® Dictionary, Fourth Edition<br /><br /><br /> The dictionary gives you more than just a definition. It also provides an <br /> audio (WAV file) pronunciation guide and a link to a thesaurus entry for <br /> the defined word.<br /><br /><br /><br /><br /> The American Heritage® Spanish Dictionary, Second Edition<br /><br /><br /> The Spanish dictionary lets you type in either English or Spanish words <br /> and returns the appropriate translation. It does not, however, provide an <br /> audio pronunciation guide.<br /><br /><br /><br /><br /> Roget's II: The New Thesaurus<br /><br /><br /> The thesaurus provides a list of related words. But, since this is a web <br /> thesaurus, it also links each related word to that word's own thesaurus <br /> entry, letting you drill deeply in the population of related terms.<br /><br /><br /><br /><br /> Columbia Encyclopedia<br /><br /><br /> The encyclopedia is based on the single-volume reference book that was <br /> once the staple for many students, who used it for quick fact lookups. <br /> Although it does not have the depth or breadth of for-fee products such as <br /> MSN Encarta, it is a good starting point for research.<br /><br /><br /><br /><br /> Bartlett's Familiar Quotations<br /><br /><br /> The quotes are from the 10th edition, published in 1919. It has indexes <br /> alphabetized by authors and quotations, and searchable by keyword.<br /><br /><br /><br /><br /> Gray's Anatomy of the Human Body<br /><br /><br /> This electronic version is based on the 1918 edition. It provides <br /> descriptions of anatomical structures and 1,247 illustrations.<br /><br /><br /><br /><br /> The Oxford Shakespeare<br /><br /><br /> This electronic version of the complete works of William Shakespeare is <br /> based on the edition published in 1914. A complete text search of the <br /> works is available and returns the location of the search text, down to <br /> the line number of a specific play, sonnet, or other work.<br /><br /><br /><br /><br /> World Factbook<br /><br /><br /> The World Factbook is maintained by the U.S. Government and placed in the <br /> public domain. The Factbook provides facts about the countries of the <br /> world as well as flag drawings and 267 color maps. The audio pronunciation <br /> guide requires the Apple Quicktime plugin.<br /><br /><br /><br /><br /> Conversion Calculator<br /><br /><br /> This easy-to-use unit conversion tool lets you quickly convert values for <br /> area, length, volume, and mass.<br /><br /><br /> By combining these sources into one site, Yahoo! has made it easy to <br /> search all of these sources at once. If you're putting together a paper <br /> about the planet Saturn, for instance, you can browse to <br /> http://reference.yahoo.com/, type Saturn into the search form, choose All <br /> Reference from the drop-down menu, and click Search. You'll find a page of <br /> search results from these specific sources, as shown in Figure 2-56.<br /><br /><br /><br /><br /> Figure 2-56. Search Results for "Saturn" at Yahoo! Reference<br /><br /><br /><br /><br /><br /> If you're doing academic work, these results can be more manageable than <br /> what you get from typing Saturn into the web search form at Yahoo!, and <br /> you'll know the information you find is from established reference books <br /> that have been used in the classroom for decades.<br /><br /><br /> 2.19.2. Programmatic Access<br /><br /><br /> Yahoo! doesn't provide access to these reference books through its web <br /> services API, but with some attention to URLs and a look at the HTML, you <br /> can screen scrape any information you need from one of these sources. For <br /> example, searching the Yahoo! Bartlett's Familiar Quotations returns a <br /> list of quotes with the search word or phrase in a bulleted list. And a <br /> simple Python script can take advantage of the fixed web presentation <br /> style to create a quick list of results.<br /><br /><br /> 2.19.2.1. The code.<br /><br /><br /> This script lets you retrieve a list of encyclopedia entries related to a <br /> search word argument passed to the script. The script builds a Yahoo! <br /> Research URL with the incoming term, downloads the HTML, separates the <br /> contents by HTML tag, and then prints out the results. The results can be <br /> collected in a text file to provide you with a number of quotations with a <br /> specific word or phrase.<br /><br /><br /> Save the following code to a file called YahooQuotations.py:<br /><br /><br /> #!/usr/bin/python<br /> import sys<br /> import urllib<br /><br /><br /> def processline(quoteline):<br /> tagstart = "<" # start of an HTML tag<br /> tagend = ">" # end of an HTML tag<br /> tagon = STOP<br /> stringcollect = ""<br /> for yahoochar in quoteline:<br /> if (yahoochar == tagstart):<br /> tagon = START<br /> elif (yahoochar == tagend):<br /> tagon = STOP<br /> continue # Do not print the > character itself<br /> if (tagon == STOP): # get everything between HTML tags<br /> stringcollect += yahoochar<br /> return stringcollect.strip( )<br /> myword = str(sys.argv[1]) # word to search for in quotations<br /> quotationurl = "http://education.yahoo.com/search/bfq?p="<br /> searchword = quotationurl + myword<br /> START = 1<br /> STOP = 0<br /> quoteon = STOP<br /> f = urllib.urlopen(searchword)<br /> for line in f.readlines( ):<br /> if (line.find("<li>") > -1): # display quotation search results<br /> quoteon = START<br /> elif (line.find("<'/li>") > -1):<br /> quoteon = STOP<br /> print "==================="<br /> elif (line.find("-end search") > -1): # ignore bullet points after <br /><br /><br /><br /> results<br /> break<br /> if (quoteon == START):<br /> print processline(line) # print quotation without HTML tags<br /><br /><br /><br /><br /> 2.19.2.2. Running the hack.<br /><br /><br /> To run the script, type the following at the command line:<br /><br /><br /> YahooQuotations.py insert keyword <br /><br /><br /><br /><br /> You should see a list of quotes matching the term you used. And by piping <br /> the results of the program to a text file, you can build a text file <br /> filled with quotes. If you're interested in finding famous historic <br /> quotations related to planets, you might run the script like this:<br /><br /><br /> YahooQuotations.py planets > planets_quotes.txt<br /><br /><br /><br /><br /> Figure 2-57 shows the text file that was built with this command.<br /><br /><br /><br /><br /> Figure 2-57. A text file filled with quotes from Yahoo! Reference<br /><br /><br /><br /><br /><br /> Even if you're not looking to automatically add quotes to a text file, you <br /> might find that the Yahoo! Reference web site will help you get a <br /> jumpstart on a school paper, teach you more about the world, or settle a <br /> bet between friends.<br /><br /><br /> Todd Ogasawara<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 41. Find and Rate Movies<br /><br /><br /><br /><br /><br /> You can find showtimes, review movies, and get recommendations at Yahoo! <br /> Movies.<br /><br /><br /> You can streamline your movie-viewing habits by using <br /> http://movies.yahoo.com/ or by typing movies! into any Yahoo! search form. <br /> Yahoo! Movies is designed to help you find what movies are out, which <br /> movies are hot, and where you can see them. Here's a quick look at some of <br /> the features you'll find on the site:<br /><br /><br /><br /><br /> Movie Showtimes<br /><br /><br /> Enter a Zip Code or City and State into the form on the front page to find <br /> a list of theaters in your area, with a complete list of movies and times <br /> they're playing.<br /><br /><br /><br /><br /> New Releases<br /><br /><br /> Click Coming Soon on the front page to see a list of movies that will be <br /> in theaters soon. Be sure to browse the Further Out column on the right <br /> side of the page to see movies opening in the more distant future.<br /><br /><br /><br /><br /> Movie Trailers<br /><br /><br /> Click Trailers on the front page or browse to <br /> http://movies.yahoo.com/trailers to view video clips and previews of <br /> movies. The archive includes movies from the past several years.<br /><br /><br /><br /><br /> Entertainment News<br /><br /><br /> Click News on the front page to view film-related news from the <br /> entertainment industry. For an overview of news from the entire <br /> entertainment business, point your browser to <br /> http://entertainment.yahoo.com/.<br /><br /><br /><br /><br /> Box Office Charts<br /><br /><br /> Click Box Office to find out which movies are making the most money. You <br /> can view the rankings by day or week, or view the top-grossing movies of <br /> all time. You can also choose archived charts from the past few months to <br /> see how recent movies have done at the box office.<br /><br /><br /><br /><br /> Movie Details<br /><br /><br /> Click the title of any movie to find a detailed movie info page that <br /> includes cast and credits, photos, reviews from critics and other Yahoo! <br /> users, and a message board for discussing the movie.<br /><br /><br /> 2.20.1. Find Movie Showtimes<br /><br /><br /> Yahoo! Movies gathers showtimes from every theater and makes them <br /> available in one place. Instead of scanning through a newspaper or looking <br /> up theater phone numbers and listening through their menus, you can <br /> quickly find showtimes via the Web, email, or even cell phone.<br /><br /><br /> 2.20.1.1. Showtimes page.<br /><br /><br /> The most direct way to look up showtimes for your area is through the <br /> Showtimes page at Yahoo! Movies. You can type your Zip Code into the form <br /> on the front page or you can use predictable URLs to bookmark your <br /> theaters. Here's the format for the Showtimes page URL:<br /><br /><br /> http://movies.yahoo.com/showtimes/showtimes.html?z=insert zip code<br /><br /><br /><br /><br /> Add your Zip Code and bookmark the page to have your local theater <br /> schedules one click away. If you don't know the Zip Code for a particular <br /> area, you can also use a city and state combination in place of the Zip <br /> Code, using a plus sign instead of spaces. So, you could bring up a list <br /> of theaters and showtimes in Sebastopol, California, with either of the <br /> following URLs:<br /><br /><br /> http://movies.yahoo.com/showtimes/showtimes.html?z=95472<br /> http://movies.yahoo.com/showtimes/showtimes.html?z=Sebastopol+CA<br /><br /><br /><br /><br /><br /><br /> You'll see that some showtimes at some listed theaters are <br /> also links. You can click the link to buy tickets to that <br /> showing at Yahoo! partner Fandango, and you won't have to <br /> stand in line when you get to the theater!<br /><br /><br /><br /><br /><br /><br /> If you'd rather just see a list of all the movies playing in your area, <br /> you can click the View By: Movie Title link on the Showtimes page or use <br /> the following URL format:<br /><br /><br /> http://movies.yahoo.com/showtimes/allmovies?z=insert zip code<br /><br /><br /><br /><br /> The Movie Titles page lists all of the movies playing in your area, along <br /> with the rating and total running time for each movie. You can click the <br /> movie title to see the theaters where the movie is playing and the <br /> showtimes.<br /><br /><br /> If you're logged in to Yahoo!, you can customize the Showtimes page with <br /> your favorite theaters. Next to any theater listed, click the "Add to My <br /> Favorite Theaters" link. To add several theaters at once, click Edit next <br /> to the Favorite Theaters title (customized with your own Yahoo! ID) at the <br /> top of the page. Once your favorites are set, you can limit lists of <br /> movies and showtimes by theater location.<br /><br /><br /> 2.20.1.2. Email newsletter.<br /><br /><br /> To receive a weekly email with showtimes at theaters in your area, scroll <br /> to the bottom of any page at Yahoo! Movies and click the "Get Yahoo! <br /> Movies in Your Mailbox" link. The sign-up form requires your Zip Code and <br /> will ask a few optional questions about your movie-going habits. The email <br /> itself is a scaled-down version of the Yahoo! Movies web site, and you'll <br /> get movie news and info about new releases.<br /><br /><br /> 2.20.1.3. Cell phone schedule.<br /><br /><br /> For the ultimate in convenience, you can look up movie showtimes on any <br /> cell phone with a web browser. The path to Yahoo! Mobile will vary by cell <br /> phone provider, but you can always manually type in the URL <br /> http://mobile.yahoo.com/ if you don't see a link to Yahoo! when you start <br /> your phone's browser.<br /><br /><br /> Once you're at the mobile site, you can either log in with your Yahoo! ID <br /> to see the times at your favorite theaters, or you can scroll to the <br /> Movies link and enter a Zip Code. You should see a list of theaters you <br /> can click on, as shown in Figure 2-58.<br /><br /><br /><br /><br /> Figure 2-58. Theater listings on a cell phone browsing Yahoo! Mobile<br /><br /><br /><br /><br /><br /><br /><br /> Entering or changing your preferred Zip Code is particularly <br /> handy if you're on the road and aren't familiar with the local <br /> theaters.<br /><br /><br /><br /><br /><br /><br /> Click on a theater to see a list of the movies and showtimes like the one <br /> shown in Figure 2-59.<br /><br /><br /> Clicking a movie title will show you all of the theaters in the area that <br /> are playing the movie, along with an image of the movie poster, as shown <br /> in Figure 2-60, if your phone supports images.<br /><br /><br /> Carrying Yahoo! Movies around in your pocket means you can be a bit more <br /> spontaneous with your movie choices, and you won't have to plan your <br /> viewing in front of your computer before you leave the house.<br /><br /><br /> 2.20.2. Connect with Movie Fans<br /><br /><br /> In addition to the official information available about movies, Yahoo! <br /> Movies lets you read reviews, add your own reviews, and find out what <br /> other movie fans think, in a number of different ways.<br /><br /><br /> 2.20.2.1. Create your profile.<br /><br /><br /> To get started, click the My Movies tab on the Yahoo! Movies front page. <br /> Click the Edit links next to different elements of the page to add your <br /> Real Name, Location, a bit about you, and your favorite movie genres. When <br /> you're done, you should see a completed profile page like the one shown in <br /> Figure 2-61.<br /><br /><br /><br /><br /> Figure 2-59. Movie listings on a cell phone browsing Yahoo! Mobile<br /><br /><br /><br /><br /><br /><br /><br /> Figure 2-60. An individual movie listing on a cell phone browsing Yahoo! <br /> Mobile<br /><br /><br /><br /><br /><br /> Your profile page collects some of your Yahoo! Movies contributions into <br /> one place. As you review movies or create lists of movies, they'll be <br /> listed on your profile page. That way, someone who enjoys a list or review <br /> you've added can browse other contributions you've made.<br /><br /><br /> Movie lists let you bring some order to the universe of movies by <br /> gathering them together into groups. You can put lists together based on <br /> any criteria you see fitanything from your personal favorites, to an <br /> obscure category that you might be familiar with. Figure 2-62 shows a <br /> custom list open for editing.<br /><br /><br /><br /><br /> Figure 2-61. Yahoo! Movies profile page<br /><br /><br /><br /><br /><br /><br /><br /> Figure 2-62. A Yahoo! Movies list<br /><br /><br /><br /><br /><br /> To add movies to a list, you can search by title and choose from the <br /> search results. You can also look for an "Add to My Movies" link as you're <br /> browsing movies at the site. Clicking the link will let you add the movie <br /> to one or more of your existing lists.<br /><br /><br /> You can also add your own review of any movie past or present, and Yahoo! <br /> has a great set of guidelines to keep in mind while you're writing. You <br /> can read their guidelines at <br /> http://help.yahoo.com/help/us/movies/movies-13.html.<br /><br /><br /> 2.20.2.2. Get recommendations.<br /><br /><br /> As you browse the movies at Yahoo! Movies, you can assign letter grades <br /> with a plus or minus to any movie, if you're logged in with your Yahoo! <br /> ID. If you hate the latest Star Wars, you can give it an F. If you're <br /> lukewarm on the latest romantic comedy but thought it was good for a <br /> laugh, you could give it a C+. After you've rated a few movies, Yahoo! <br /> will start to know what types of movies you prefer and will offer <br /> recommendations in four areas:<br /><br /><br /><br /> Movies in Theaters <br /><br /><br /><br /> Movies on TV <br /><br /><br /><br /> New releases on DVD/VHS <br /><br /><br /><br /> Movie fans like you <br /><br /><br /> Figure 2-63 shows a personalized recommendations page.<br /><br /><br /><br /><br /> Figure 2-63. Yahoo! Movies recommendations<br /><br /><br /><br /><br /><br /> If you're ever stumped about what movies to see or rent, a trip to the <br /> Yahoo! Movies recommendations page could clue you in to some movies you <br /> don't already know about. As Alfred Hitchcock said, "A good film is when <br /> the price of the dinner, the theater admission, and the babysitter were <br /> worth it." And with a little time and effort at Yahoo! Movies, you can <br /> make sure the films you watch are good and worth the cost.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 42. Subscribe to Movie Showtimes<br /><br /><br /><br /><br /><br /> With some quick scripting, subscribe to your favorite theaters to keep up <br /> with the movies they're playing.<br /><br /><br /> Even though there are a number of ways to keep up with ever-changing movie <br /> schedules at Yahoo! Movies [Hack #41], if you already use an RSS <br /> newsreader, you can start watching your favorite theaters with just a bit <br /> of scripting.<br /><br /><br /> RSS is an XML syndication format that's great for keeping up with changing <br /> informationtypically news storiesand Yahoo! offers RSS for many features <br /> of its site. You can add any data that's available as RSS to a newsreader <br /> and see any changes or additions on a regular basis. Unfortunately, at the <br /> time of this writing, Yahoo! doesn't provide movie schedules via RSS, so <br /> if you want to see showtimes in your newsreader, you'll need to build a <br /> feed yourself.<br /><br /><br /> 2.21.1. Finding Your Theaters<br /><br /><br /> Yahoo! doesn't offer movie schedules through their web services API, so <br /> this hack relies on screen scraping to gather the information. Screen <br /> scraping refers to downloading the HTML on the web site with a script and <br /> processing it to find relevant pieces of information. Keep in mind that <br /> screen scraping is a very brittle process, and if Yahoo! changes the HTML <br /> used to display movie times even slightly, the code in this hack will have <br /> to be modified to keep up with the changes.<br /><br /><br /> To download the schedule page, you first need to know how to get there. <br /> Each theater listed at Yahoo! Movies has a unique internal ID number. But <br /> it's fairly easy to find this number, because it's exposed in the URL. <br /> Simply browse to Yahoo! Movies (http://movies.yahoo.com/) and enter your <br /> Zip Code into the form labeled Get Showtimes and Tickets.<br /><br /><br /> You should see a list of theaters in your area, along with movie <br /> showtimes. Under each theater title is link for Theater Info. Click the <br /> link and note the URL in your browser address bar, which will include the <br /> theater ID. As you'd expect, the four-to five-digit number following the <br /> variable named id in the URL is the theater ID for that theater. Jot down <br /> the IDs of your favorite theaters, because you'll need them to generate <br /> RSS feeds later.<br /><br /><br /> Once you know the internal ID of a specific theater, you can link directly <br /> to the theater detail page on Yahoo! Movies with the following URL format:<br /><br /><br /> http://movies.yahoo.com/showtimes/theater?id=insert theater ID<br /><br /><br /><br /><br /> The theater detail page contains the theater's address and phone number, a <br /> list of services available, and the current schedule of movies. For this <br /> hack, the only relevant pieces of data are the theater title and the list <br /> of movies. Some Perl can isolate those elements and turn them into an RSS <br /> feed you can subscribe to.<br /><br /><br /> 2.21.2. The Code<br /><br /><br /> This code relies on a single Perl module: XML::RSS::SimpleGen by Sean <br /> Burke. This module makes it easy to create an RSS feed with screen <br /> scraping, and it keeps the tough work of formatting the feed properly in <br /> the background.<br /><br /><br /> Save the following code to a file called theater_rss.pl:<br /><br /><br /> #!/usr/bin/perl<br /> # theater_rss.pl<br /> # Accepts a Yahoo! Movies theater ID and prints<br /> # an RSS feed of currently playing movies.<br /> # Usage: theater_rss.pl <theater_ID><br /> #<br /> # You can find theater IDs at Yahoo! Movies<br /> # at http://movies.yahoo.com/<br /><br /><br /> use strict;<br /> use XML::RSS::SimpleGen;<br /><br /><br /> # Grab the incoming theater ID<br /> my $tid = join(' ', @ARGV) or die "Usage: theater_rss.pl <theater_ID>\n";<br /> my $theater_title = "My favorite theater";<br /><br /><br /> # Set the theater schedule URL<br /> my $url = "http://acid1.oa.yahoo.com/mbl/mov/tdet?tid=$tid";<br /><br /><br /> # Download the schedule page<br /> my $content = get_url($url);<br /><br /><br /> # Find the theater name<br /> if ($content =~ m!<dl><dt>(.*?)</dt>!sg) {<br /> $theater_title = $1;<br /> }<br /><br /><br /> # Start the RSS Feed<br /> rss_new($url, "$theater_title Schedule");<br /> rss_language('en');<br /> rss_webmaster('insert your email address');<br /><br /><br /> rss_daily();<br /><br /><br /> # Set the regular expression to find data<br /> my $regex = '<table.*?>.*?mid=(.*?)">(.*?)</a></td>.*?';<br /> $regex .= '<td>(.*?)</td>.*?</table>';<br /><br /><br /> # Loop through the HTML, grabbing elements<br /> while ($content =~ m!$regex!sg) {<br /> # rss_item accepts url, title, description.<br /> my $url = "http://movies.yahoo.com/shop?d=hv&cf=info&id=$1";<br /> rss_item($url, $2, $3);<br /> }<br /><br /><br /> # Warn if nothing was found<br /> die "No items in this content?! {{\n$_\n}}\nAborting"<br /> unless rss_item_count();<br /><br /><br /> # Save the rss file as <theater_ID> .rss<br /> rss_save("$tid.rss");<br /> exit;<br /><br /><br /><br /><br /> This code accepts a theater ID, builds the appropriate Yahoo! Movies URL, <br /> downloads the HTML, and picks through the HTML with some regular <br /> expressions to find theater and movie information. The code uses the <br /> functions that are a part of XML::RSS::SimpleGen to create and save an RSS <br /> file based on the movie information.<br /><br /><br /> The name of the RSS file this script generates is based on the incoming ID <br /> and will be theater_ID .rss. If you'd rather save the file to another <br /> location, just append the path to the filename where the script calls the <br /> rss_save function. Be sure that the file this script creates is in a <br /> location that's accessible via the Web.<br /><br /><br /> 2.21.3. Running the Hack<br /><br /><br /> You can run the script once by passing in a theater ID on the command <br /> line, like this:<br /><br /><br /> perl theater_rss.pl insert theater ID <br /><br /><br /><br /><br /> But the real value of the script is that you can run it on a regular <br /> schedule on a web server to keep up with changes to the theater's <br /> schedule. Once per day should be enough to keep up with changes, and you <br /> can set the script to run regularly with Windows Scheduler or the Unix <br /> cron command.<br /><br /><br /> On Windows servers, you can find the scheduler at Start Settings Control <br /> Panel Scheduled Tasks. Click Add Scheduled Task at the top of the list to <br /> start the task wizard and set the program to run like this:<br /><br /><br /> C:\perl\bin\perl.exe "C:\path\to\theater_rss.pl insert theater ID"<br /><br /><br /><br /><br /> You might need to adjust the location of the Perl executable, depending on <br /> where it's installed on your server. You'll also need to include the full <br /> path to theater_rss.pl.<br /><br /><br /> On Unix-based systems, you can run the script once per day by adding an <br /> entry like the following to your crontab file:<br /><br /><br /> 52 23 * * * ~/theater_rss.pl insert theater ID<br /><br /><br /><br /><br /> If you want to subscribe to more than one theater in your area, set up a <br /> separate recurring task for each theater, using its unique theater ID.<br /><br /><br /> Finally, add the new RSS feed to your favorite newsreader and you'll find <br /> out about any new movies playing at that theater. Figure 2-64 shows a <br /> subscription to theater 8193Carmike Cinema 12 in Corvallis, Oregonin the <br /> latest version of the Safari browser (which doubles nicely as an RSS <br /> newsreader).<br /><br /><br /><br /><br /> Figure 2-64. A theater schedule RSS feed in Safari<br /><br /><br /><br /><br /><br /> Clicking "Read more…"or the movie title in some newsreaderswill take you <br /> to the movie detail page at Yahoo! Movies, where you can find out more <br /> about that particular movie. And by subscribing to your favorite local <br /> theaters' schedules, you'll always be on top of new additions to their <br /> lineups.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 43. View Movie Lists on Your Cell Phone<br /><br /><br /><br /><br /><br /> Next time you go to the video store, take a Yahoo! Movies list with you on <br /> your cell phone.<br /><br /><br /> Imagine you find yourself in a video store, searching for the perfect <br /> movie among the thousands of choices and drawing a blank. Even though you <br /> might have a mental list of several movies you've been meaning to see, it <br /> always seems those crucial bits of information aren't available when you <br /> need them. If you have a cell phone with web access, Yahoo! Movies and <br /> some Perl scripting can get you out of this jam.<br /><br /><br /> This hack takes advantage of the Lists feature at Yahoo! Movies [Hack <br /> #41], which is designed to put movies together into a group. By creating a <br /> list of movies you'd like to see, you'll have the movies in a convenient <br /> format for scripting. From there, the hack uses some Perl to convert the <br /> Yahoo! Movies list into Wireless Markup Language ( WML) that you can view <br /> on your phone.<br /><br /><br /> 2.22.1. Creating Your List<br /><br /><br /> To get started, you need to turn your mental list of movies you'd like to <br /> see into something more tangible. Browse to <br /> http://movies.yahoo.com/profiles and click Create New List. If you don't <br /> already have a Yahoo! ID [Hack #3], you'll need to create one in order to <br /> use the movie list feature. Choose "Movies I Want to See" from the <br /> suggestions list or create your own title. Now you'll have a blank list <br /> waiting for some entries.<br /><br /><br /> At the top of the page, you should see a form titled Search Yahoo! Movies. <br /> Type in the name of a movie you'd like to see. If you don't have anything <br /> in mind, try typing Buckaroo Banzai. Click Search and you should see a <br /> result with the 1984 cult classic The Adventures of Buckaroo Banzai. Click <br /> the "Add to My Movies" link next to the title, and you'll see a list of <br /> your movie lists. Click the checkbox next to the list you just created and <br /> then click "Add to List." The movie will be on your list, and you can <br /> repeat the process as many times as you need to until your movie list is <br /> filled with films you'd like to see, as shown in Figure 2-65.<br /><br /><br /> Once your movie list is ready to go, you just need to jot down its URL. <br /> Head back to your profile page by clicking the My Movies tab or browsing <br /> to http://movies.yahoo.com/profiles.Click the title of your movie list and <br /> copy the URL from your browser's address bar. The URL should look <br /> something like this:<br /><br /><br /> http://movies.yahoo.com/mvc/dls?iid=7-2022263&lid=7-150274<br /><br /><br /><br /><br /> With the movie list URL in hand, you're ready to build the script that <br /> will convert that list into a cell phonefriendly format.<br /><br /><br /><br /><br /> Figure 2-65. A Yahoo! Movies list<br /><br /><br /><br /><br /><br /> 2.22.2. The Code<br /><br /><br /> This script needs to run on a publicly available web server that can <br /> execute Perl scripts. You'll need the nonstandard Perl module LWP::Simple, <br /> which will fetch the movie list from Yahoo! Movies. You'll also need <br /> HTML::TableExtract, which will do the tough work of deconstructing the <br /> HTML for you.<br /><br /><br /> This script relies on screen scraping to gather the movies in a list, <br /> which means it's picking through the HTML to find relevant information. <br /> This also means that if Yahoo! changes their movie list HTML, even <br /> slightly, this script will likely fail. Keep in mind that you might need <br /> to tinker with the script to keep up with changes to Yahoo! Movies.<br /><br /><br /> To keep your fingers from doing too much work when you're ready to bring <br /> it up on your phone, you'll want to keep the name of this script short. <br /> Save the following code to a file called m.cgi and be sure to include your <br /> unique movie list URL as the value of $listURL at the top of the script:<br /><br /><br /> #!/usr/bin/perl<br /> # m.pl<br /> # Convert a Yahoo! Movies list into WML for cell phones<br /> # Usage: m.cgi<br /><br /><br /> use strict;<br /><br /><br /> use HTML::TableExtract;<br /> use LWP::Simple;<br /><br /><br /> # Set your Yahoo! Movie list URL<br /> my $listURL = "insert your movie list URL";<br /><br /><br /> # Set the base movie URL<br /> my $movieURL = "http://acid1.oa.yahoo.com/mbl/mov/mdet?mid=";<br /><br /><br /> # Set the titles of the Yahoo! Movies table you're parsing. note<br /> # that if the title contains HTML, so too must these headers.<br /> my @tehs = ["#", "Movie Title", "User<br>Grade",<br /> "Avg. User<br>Grade", "Critics<br>Grade","Status"];<br /> my $te = HTML::TableExtract->new(headers=>@tehs, keep_html=>1);<br /><br /><br /> # Fetch the HTML<br /> my $content = get($listURL);<br /><br /><br /> my ($wml,@moviedata);<br /><br /><br /> # Parse the table that matches the headers above.<br /> $te->parse($content);<br /> foreach my $ts ($te->table_states) {<br /> foreach my $r ($ts->rows) {<br /> next if @$r[0] =~ /grayText/; # final table footer.<br /> my ($title, $mid); # parse ID and title from "Movie Title" field.<br /> if (@$r[1] =~ m!.*?id=(.*?)"><b>(.*?)</b>.*?!gis) {<br /> $mid = $1; $title = $2;<br /> }<br /><br /><br /> my $thisMovie = {<br /> title=> $title,<br /> mid => $mid,<br /> grade => &clean_text(@$r[2]),<br /> avg=> &clean_text(@$r[3]),<br /> critics => &clean_text(@$r[4]),<br /> status => &clean_text(@$r[5]),<br /> };<br /> push @moviedata, $thisMovie;<br /> } <br /> }<br /><br /><br /> # Assemble the WML by looping through the array of hashes<br /> for my $i ( 0 .. scalar(@moviedata)-1) {<br /> $wml .= "<anchor>$moviedata[$i]{title} ";<br /> $wml .= "<go href=\"$movieURL$moviedata[$i]{mid}\"/>";<br /> $wml .= "</anchor><br />\n";<br /> $wml .= "<b>Status:</b> $moviedata[$i]{status}<br />\n";<br /> $wml .= "<b>Critics:</b> $moviedata[$i]{critics}<br />\n";<br /> $wml .= "<b>Users:</b> $moviedata[$i]{avg}\n";<br /> $wml .= "<br /><br />\n";<br /> }<br /><br /><br /> # Send final WML to the client<br /> print "Content-Type: text/vnd.wap.wml\n\n";<br /><br /><br /> print "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";<br /> print "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\"";<br /> print "\"http://www.wapforum.org/DTD/wml_1.1.xml\">\n";<br /> print "<wml><card id=\"Menu\" title=\"Movie Wishlist\">\n";<br /> print "<p><b>Movie Wishlist</b><br/><br />\n";<br /> print $wml;<br /> print "</p></card></wml>\n";<br /><br /><br /> # This function removes HTML, space entities,<br /> # linebreaks, and leading/trailing spaces from strings<br /> sub clean_text() {<br /> my $text = shift(@_);<br /> $text =~ s!<.*?>!!g;<br /> $text =~ s! !!g;<br /> $text =~ s!\n!!g;<br /> $text =~ s!^\s+!!;<br /> $text =~ s!\s+$!!;<br /> $text =~ s!\s{16}!, !;<br /> return $text;<br /> }<br /><br /><br /><br /><br /> This script downloads the HTML from the URL you supply and picks relevant <br /> information from the HTML. When the script runs into a movie title, it <br /> also grabs the internal Yahoo! ID for that movie. Then, using the <br /> $movieURL as a base, the script assembles a link to that movie's detail <br /> page at Yahoo! Mobile. This means that if you're ever browsing your list <br /> on your phone and can't quite remember what that particular movie is <br /> about, you can simply click through to Yahoo!'s mobile site to get a <br /> summary of the movie.<br /><br /><br /> In addition to the titles in the list, the script includes whether the <br /> movie is in theaters or on DVD, the critics' grade, and the average grade <br /> assigned by Yahoo! users.<br /><br /><br /> Notice that at the end of the script, when it's printing out the WML, the <br /> content type is set as text/vnd.wap.wml. Setting this content type ensures <br /> that the device viewing the page will know how to render it. Web browsers <br /> won't be able to view the page, so you can either test it exclusively on <br /> your cell phone, or temporarily change the content type to text/xml in <br /> order to test it in a web browser.<br /><br /><br /> 2.22.3. Running the Hack<br /><br /><br /> Upload m.cgi to a publicly available web server and bring it up in your <br /> cell phone's browser as you would any URL:<br /><br /><br /> http://example.com/m.cgi<br /><br /><br /><br /><br /> You'll have to key in the URL by hand on your phone. But most phone <br /> browsers can set bookmarks, so you can add this to your favorite mobile <br /> sites for one-click access in the future. On your phone, you should see <br /> your movie list, as shown in Figure 2-66.<br /><br /><br /><br /><br /> Figure 2-66. A Yahoo! Movies list on a cell phone<br /><br /><br /><br /><br /><br /> Of course, you'll have to do the work of keeping your to-see list <br /> up-to-date. You'll need to revisit your list frequently to add movies <br /> you'd like to see or remove those you've seen. With an active list and <br /> your cell phone in your pocket, you'll never be faced with drawing a blank <br /> as you browse movies!<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 44. Plan Your TV Viewing<br /><br /><br /><br /><br /><br /> Yahoo! TV can help you plan what to watch and when to watch it.<br /><br /><br /> Television is a big part of our lives; according to the Bureau of Labor <br /> Statistics, people spend about half of their leisure time watching TV. If <br /> you've ever started a long channel-surfing binge, you know that you can <br /> feel you've wasted that leisure time by the time you're done. Even though <br /> we now have hundreds of channels to choose from, it can still be hard to <br /> find something to watch.<br /><br /><br /> It shouldn't be a surprise that TV Guide is one of the top-selling <br /> magazines in the country. It takes a bit of energy to really find what <br /> you're interested in, and Yahoo! TV can help you plan so you won't be <br /> wasting your time scanning. To get to Yahoo! TV, browse to <br /> http://tv.yahoo.com/ or type tv! into any Yahoo! Search form. Here's a <br /> look at what you'll find at the site:<br /><br /><br /><br /><br /> TV Listings<br /><br /><br /> Enter your Zip Code at http://tv.yahoo.com/grid, and you'll find what <br /> shows are on each of your channels, whether you have cable, satellite, or <br /> rabbit ears. You can view shows by time and date, limit listings to <br /> certain categories, or create a custom lineup of your favorite channels.<br /><br /><br /><br /><br /> Picks from Yahoo! Editors<br /><br /><br /> Yahoo! TV editors offer their take on the best bets for viewing, as well <br /> as brief synopses of the shows at http://tv.yahoo.com/picks. You can take <br /> a look at editors' choices for that day or move back or forward a few <br />days.<br /><br /><br /><br /><br /> TV News and Gossip<br /><br /><br /> Find out what's happening in the television industry and what TV <br /> celebrities are up to. You can even read about celebrities at their worst <br /> from several different supermarket tabloids at <br /> http://tv.yahoo.com/entgossip.<br /><br /><br /><br /><br /> Nielsen Ratings<br /><br /><br /> Find out which shows had the highest numbers of viewers for the week, as <br /> calculated by Nielsen. You'll find the Top 20 at <br /> http://tv.yahoo.com/nielsen.<br /><br /><br /><br /><br /> TV Show Database<br /><br /><br /> You can look up television shows to read a brief synopsis, see photographs <br /> of the actors, and review descriptions of upcoming episodes. Browse to <br /> http://tv.yahoo.com/db and search alphabetically or by genre. The database <br /> contains listings for shows from the late 1980s through today.<br /><br /><br /><br /><br /> Soap Opera Synopses<br /><br /><br /> Miss an episode of your favorite soap? Browse to http://tv.yahoo.com/soaps <br /> and you'll be caught up on who was sleeping with whom and whether their <br /> amnesia has worn off.<br /><br /><br /><br /><br /> Message Boards<br /><br /><br /> Discuss shows with other Yahoo! users at the Yahoo! Message Boards by <br /> browsing to http://messages.yahoo.com/ and clicking the TV link under Hot <br /> Topics on the left side of the page. You can also find many Yahoo! Groups <br /> devoted to specific programs or general TV discussion at <br /> http://tv.dir.groups.yahoo.com/.<br /><br /><br /> 2.23.1. Personalize Your Listings<br /><br /><br /> One of the most useful features is personalized TV listings. To <br /> personalize your listings, bring up the Yahoo! TV site <br /> (http://tv.yahoo.com/) and sign in with your Yahoo! ID [Hack #3] by <br /> clicking the Sign In link on the right side of the page. If you don't have <br /> a Yahoo! ID, you can still temporarily personalize the TV listings by <br /> clicking the My Listings link, but keep in mind that your listings won't <br /> be available across different browsers and computers you use without <br /> signing in, and you won't be able to save your favorite channels.<br /><br /><br /> You'll need to enter your Zip Code, which will narrow your choices down to <br /> cable, broadcast, and satellite listings for your area. Choose your <br /> provider from those listed and click Go!. You should see listings for all <br /> of the channels you receive. Click the Create Personalized Listings link <br /> at the top of the page to create a list of your favorite channels. <br /> Highlight a channel on the left and click the Add button; the channel will <br /> appear in the Your Choices box on the right.<br /><br /><br /> You can also set your display preferences and a preferred start time. You <br /> can either display the first 15, 30, or 45 channels, or just display your <br /> favorite channels. You can also set the start time as 7:00 or 8:00 p.m. to <br /> display prime-time shows as your default display. Setting these <br /> preferences lets Yahoo! know which listings to show in My Yahoo!.<br /><br /><br /> Click Finished and you should see a list of what's currently playing on <br /> your favorite channels, as shown in Figure 2-67.<br /><br /><br /><br /><br /> Figure 2-67. A schedule of Favorite Channels at Yahoo! TV<br /><br /><br /><br /><br /><br /> Once your favorites are set, you can also keep tabs on the schedule at My <br /> Yahoo! (http://my.yahoo.com/). Figure 2-68 shows listings on My Yahoo!, <br /> with favorite channels set to begin at 8:00 p.m.<br /><br /><br /> If you'd rather not visit a Yahoo! web site to view your schedule, Yahoo! <br /> doesn't offer any options for you yet. But with some Perl scripting, you <br /> can create your own options.<br /><br /><br /> 2.23.2. Email Your Listings<br /><br /><br /> If you're more of an email person than a web person and prefer to read <br /> information in your inbox instead of a browser, some quick scripting can <br /> take care of that for you. This hack relies on screen scraping to gather <br /> data, and the usual caveats apply, because any change to the HTML that <br /> Yahoo! uses to display TV listings could break this script. Be aware that <br /> you might need to tweak this code from time to time.<br /><br /><br /><br /><br /> Figure 2-68. The TV Listings module at My Yahoo!<br /><br /><br /><br /><br /><br /> To run this hack, you'll need your Yahoo! TV personalized listings URL and <br /> a computer that can run Perl scripts. If you haven't already personalized <br /> your listings, you'll need to back up and set your location and TV <br /> provider. Once it's set up, browse to the Yahoo! TV front page <br /> (http://tv.yahoo.com/) and click on the My Personalized Listings link at <br /> the top of the page. Note the URL in your browser's address bar. It should <br /> look something like this:<br /><br /><br /> http://tv.yahoo.com/grid?lineup=us_OR36403&zip=97333<br /><br /><br /><br /><br /> You'll need to add this URL to the code so the script knows where to get <br /> your listings.<br /><br /><br /> 2.23.2.1. The code.<br /><br /><br /> This code uses three modules that you might need to install. LWP::Simple <br /> handles fetching the TV listings and Net::SMTP sends the email the script <br /> builds. As you'd expect, Date::Format handles some simple date formatting.<br /><br /><br /><br /><br /> This script doesn't actually log in to your Yahoo! account, so <br /> you won't see your favorite channels in the email. Instead, <br /> you'll see all of the channels from your cable, satellite, or <br /> broadcast listings.<br /><br /><br /><br /><br /><br /><br /> Save the following code to a file called whats_on.pl and include your <br /> personalized listings URL, your mail server, and your email address. You <br /> can also change the value of $starthour to get listings for another time <br /> of day. It's set to 20, which is 8:00 p.m. on a 24-hour clock, and this <br /> will give you listings for prime-time shows.<br /><br /><br /><br /><br /> #!/usr/bin/perl<br /> # whats_on.pl<br /> # A script to download a Yahoo! TV schedule<br /> # and send it via email<br /> # Usage: whats_on.pl<br /><br /><br /> use strict;<br /> use LWP::Simple;<br /> use Net::SMTP;<br /> use Date::Format;<br /><br /><br /> # Set your start time in 24-hour hh format<br /> my $starthour = 20;<br /><br /><br /> # Set the Yahoo! TV URL<br /> my $url = "insert your personalized listings URL";<br /> $url .= "&starthour=$starthour&prt=1";<br /><br /><br /> # Set email info<br /> my $subject = "On TV Tonight";<br /> my $smtp_server = "insert your mail server";<br /> my $from_email = 'insert your email address';<br /> my $to_email = 'insert your email address';<br /><br /><br /> # Grab the Yahoo! TV listings page and<br /> my $body = get($url);<br /> my ($lastchannel,$out);<br /><br /><br /> # Build the email by looping through the HTML<br /> # and picking out the important stuff<br /> my $regex = '<td.*?>.*?<a href=".*?chname=(.*?)&.*?progutn=(.*?)&';<br /> $regex .= '.*?">(.*?)</a>.*?</td>';<br /> my $out = "On TV tonight--";<br /> while ($body =~ m!$regex!gis) {<br /> my $channel = $1;<br /> my $channel_f = $1;<br /> my $time = $2;<br /> my $title = $3;<br /> if ($lastchannel ne $channel) {<br /> $channel_f =~ s!\+(\d{1,2})! \($1\)!;<br /> $out .= "\n\n$channel_f\n\n";<br /> }<br /> my $airtime = time2str("%l:%M", $time);<br /> $out .= " $airtime $title\n";<br /> $lastchannel = $channel;<br /> }<br /><br /><br /> # Send the schedule via email<br /> my $dtm = time2str("%m%d%Y%T", time);<br /> my $smtp = Net::SMTP->new($smtp_server);<br /> $smtp->hello($smtp_server);<br /> $smtp->mail($from_email);<br /> $smtp->to($to_email);<br /> $smtp->data();<br /> $smtp->datasend("From: $from_email\n");<br /><br /><br /> $smtp->datasend("To: $to_email\n");<br /> $smtp->datasend("Subject: $subject\n");<br /> $smtp->datasend("Message-Id: tv.yahoo.com-sched-$dtm\@$smtp_server\n");<br /> $smtp->datasend('Content-Type: text/plain;');<br /> $smtp->datasend("\n\n");<br /> $smtp->datasend($out);<br /> $smtp->dataend();<br /> $smtp->quit;<br /><br /><br /> # Close output file<br /> close(FILE);<br /><br /><br /><br /><br /> Notice that $url holds your personalized listings URL and adds a couple of <br /> querystring variables and values, including starthour and prt=1, which <br /> sets the page to the Printable View on Yahoo!, which is easier to scrape.<br /><br /><br /> The $regex variable holds the patterns the script uses to find the <br /> relevant bits of information in the HTML, and you might need to adjust <br /> this regular expression if Yahoo! modifies their HTML.<br /><br /><br /> 2.23.2.2. Running the hack.<br /><br /><br /> To run this script once, you can just call it from the command line, like <br /> this:<br /><br /><br /> perl whats_on.pl<br /><br /><br /><br /><br /> To really take advantage of the script, set it to run daily with the <br /> Windows Scheduler or by adding a cron job on Unix-based machines. Once <br /> set, you'll receive daily emails like the one shown in Figure 2-69, with <br /> the prime-time TV schedule listed by channel.<br /><br /><br /><br /><br /> Figure 2-69. TV listings email<br /><br /><br /><br /><br /><br /> The text listing in the email is simple and includes only the channel, <br /> time, and program name. If you like to read information in your inbox, <br /> though, it's a no-frills way to find out what's going to be on TV.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 45. Create a TV Watch List<br /><br /><br /><br /><br /><br /> Combine Yahoo! TV with Yahoo! Calendar to build a custom TV schedule.<br /><br /><br /> You can find lots of information about upcoming television shows at Yahoo! <br /> TV [Hack #44]. By clicking on a program title in your personalized <br /> listings, you can find a brief synopsis of the show, members of the cast, <br /> and even directors and producers. And, of course, Yahoo! lets you search <br /> this information. Browse to Yahoo! TV (http://tv.yahoo.com/) and you'll <br /> see the search form labeled "Search listings by Keyword."<br /><br /><br /> Imagine you're a Tom Hanks fan and you'd like to find out when a show or <br /> movie he's been in will be on. Type "Tom Hanks" into the form, and click <br /> Go!. Note that the quotes are important when you're looking for a full <br /> phrase. You'll see a list of shows that Tom Hanks appears in within the <br /> next 14 days, as shown in Figure 2-70.<br /><br /><br /><br /><br /> Figure 2-70. Yahoo! TV listings search results for "Tom Hanks"<br /><br /><br /><br /><br /><br /> Who knew he was in old episodes of Happy Days? Click a title in the <br /> results and you'll find the detail page for the program. Alongside the <br /> channel and air time, you'll see an "Add to My Calendar" link. This link <br /> lets you add the show as an event on your Yahoo! Calendar so that you can <br /> track the shows you'd like to watch. And once a show is an event on your <br /> calendar, you'll receive reminders about the event in your email, which <br /> can help you remember to catch the show when it airs.<br /><br /><br /> You could run the search for Tom Hanks yourself every couple of weeks at <br /> Yahoo! TV and add any programs that look interesting. But this hack shows <br /> you how to be lazy, letting a script do the work for you. In fact, this <br /> hack will run a Yahoo! TV search for any keyword and add every result to <br /> your Yahoo! Calendar. Then you can visit your Yahoo! Calendar periodically <br /> to see what Yahoo! has suggested that you view based on your favorite <br /> keyword.<br /><br /><br /> 2.24.1. The Code<br /><br /><br /> This hack relies on the web automation module WWW::Mechanize (called Mech) <br /> and the WWW::Yahoo::Login module. This code logs in to Yahoo! TV with your <br /> Yahoo! ID and password, searches for the provided keyword, and adds all of <br /> the results to your Yahoo! Calendar. To get started, add the following <br /> code to a file called tv_watchlist.pl and include your Yahoo! ID and <br /> password in the code:<br /><br /><br /> #!/usr/bin/perl<br /> # tv_watchlist.pl<br /> # A script to gather programs from a Yahoo! TV search<br /> # and add them to a Yahoo! Calendar<br /> # Usage: tv_watchlist.pl <query><br /><br /><br /> use strict;<br /> use WWW::Yahoo::Login qw( login logout );<br /> use WWW::Mechanize;<br /><br /><br /> # Set your account info<br /> my $user = "insert Yahoo! ID";<br /> my $pass = "insert Yahoo! Password";<br /> my $count = 0;<br /><br /><br /> # Grab the incoming query<br /> my $query = join(' ', @ARGV) or die "Usage: tv_watchlist.pl <query>\n";<br /><br /><br /> # Set login URL<br /> my $url = 'http://e.my.yahoo.com/config/login?';<br /> $url .= '.intl=us&.src=tv&.done=http%3a//tv.yahoo.com/';<br /> $url .= 'grid%3f.force=p%26setlineupcookie=true';<br /><br /><br /> # Log into Yahoo! TV<br /> my $mech = WWW::Mechanize->new();<br /> my $login = login(<br /> mech => $mech,<br /> uri => $url,<br /><br /><br /> user => $user,<br /> pass => $pass,<br /> );<br /><br /><br /> # If login succeeded, add each program to calendar<br /> if ($login) {<br /> my $form = $mech->form_number(3);<br /> $mech->field("title", "\"$query\"");<br /> $mech->click();<br /> my $response = $mech->response()->content;<br /> while ($response =~ m!<a href="(http://tv.*?tvpdb.*?)">.*?</a>!gis) {<br /> my $showlink = $1;<br /> $showlink =~ s!\n!!gs;<br /> $mech->get( $showlink );<br /> $mech-> follow_link( url_regex => qr/calendar/ );<br /> $mech->follow_link( text_regex => qr/Add to/ );<br /> my $result = $mech->response()->content;<br /> if ($result =~ m!<div class="alertbox">(.*?)</div>!gis) {<br /> $count++;<br /> my $msg = $1;<br /> $msg =~ s!<.*?>!!gs;<br /> $msg =~ s!\n!!gs;<br /> print "$msg\n";<br /> }<br /> }<br /> } else {<br /> warn $WWW::Yahoo::Login::ERROR;<br /> }<br /><br /><br /> if ($count == 0) {<br /> print "No shows added.";<br /> }<br /><br /><br /><br /><br /> Because adding shows from Yahoo! TV search results to a Yahoo! Calendar <br /> can be accomplished by clicking a predictable series of links, the Mech <br /> function follow_link does most of the work in this script. A simple <br /> regular expression for either the URL or text of a link on the page tells <br /> Mech which links to follow.<br /><br /><br /> 2.24.2. Running the Hack<br /><br /><br /> To run the hack, call it from the command line and pass in a search term. <br /> Remember to enclose complete phrases in quotes, like this:<br /><br /><br /> perl tv_watchlist.pl "Tom Hanks"<br /><br /><br /><br /><br /> As the script runs, it will print a message with any shows added to your <br /> calendar, orif no shows were foundthe message "No shows added." You can <br /> pipe the output of the script to another file if you'd like to keep a log <br /> of the script's activities. Simply call the script, like so:<br /><br /><br /> perl tv_watchlist.pl "Tom Hanks" > tv_watchlist.log<br /><br /><br /><br /><br /> Figure 2-71 shows a Yahoo! Calendar with Tom Hanks shows automatically <br /> added. Each listing includes the time of the show and the channel it's on. <br /> You can even hover over a program title to see a brief synopsis of the <br /> show. And, of course, you can click the title to alter or delete the <br />event.<br /><br /><br /><br /><br /> Figure 2-71. TV shows with Tom Hanks on a Yahoo! Calendar<br /><br /><br /><br /><br /><br /> If you set the script to run every 14 days in Windows Scheduler or as a <br /> cron job, you can simply visit your Yahoo! Calendar to keep up with the <br /> watch list, or let the Yahoo! Calendar autoreminders send email messages <br /> that include program times.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 46. Develop and Share a Trip Itinerary<br /><br /><br /><br /><br /><br /> Yahoo! Trip Planner can help you organize an excursion and let you share <br /> your travel plans with others.<br /><br /><br /> Type travel! into any Yahoo! Search form and you'll find yourself at <br /> Yahoo! Travel (http://travel.yahoo.com/): a one-stop shop for planning <br /> vacations or business trips. You can find flights, hotels, and rental <br /> cars. You can read reviews from other Yahoo! users and look for special <br /> travel deals.<br /><br /><br /> Yahoo! Travel includes a feature called Trip Planner <br /> (http://travel.yahoo.com/trip) that can help you create a personalized <br /> travel guide that you can access at any time or share with others. Imagine <br /> you find yourself in charge of organizing a group trip for students; you <br /> could enter your itinerary into the Trip Planner and share it with <br /> students, parents, and teachers. Instead of printing and distributing <br /> pages of information, you can add everything at Yahoo! and pass around a <br /> URL for the itinerary. Even a smaller group going on a family vacation <br /> could benefit from having hotel, restaurant, and sightseeing details in <br /> one place.<br /><br /><br /> 2.25.1. Create a Trip<br /><br /><br /> To start a custom trip, browse to http://travel.yahoo.com/trip and click <br /> the "Create your first trip" link. You can add a name, description, and <br /> dates for the trip into the form, as shown in Figure 2-72.<br /><br /><br /><br /><br /> Figure 2-72. Create New Trip form at Yahoo! Trip Planner<br /><br /><br /><br /><br /><br /> You'll need to choose how you want to share your trip. Each trip can be <br /> Public, Private, or for a list of specific Yahoo! IDs. As you're building <br /> the trip, you might want to leave this setting as Private. You can change <br /> the sharing settings for a trip at any point in the future.<br /><br /><br /><br /><br /> Be aware that setting a trip as Public means anyone can view <br /> the details of the trip. If your trip includes notes with <br /> personally identifiable information and the dates you'll be <br /> traveling, you could be letting the world know when you won't <br /> be home!<br /><br /><br /><br /><br /><br /><br /> Your new trip is a container that can hold all of your trip plans. You can <br /> add just about anything you find at Yahoo! Travel to a trip, such as <br /> restaurants, hotels, and tourist attractions. Keep an eye out for the <br /> "Save to Trip" link as you browse or search Yahoo! Travel, and click the <br /> link to add anything you find interesting to an existing trip. Figure 2-73 <br /> shows a list of things to do around Newport, Oregon, and each listing <br /> includes the "Save to Trip" link.<br /><br /><br /><br /><br /> Figure 2-73. The "Save to Trip" link on Yahoo! Travel search results<br /><br /><br /><br /><br /><br /> If you can't find a particular location or event in Yahoo! Travel, you can <br /> add it as a custom item to your itinerary. For example, a stop at a <br /> relative's house for tea isn't going to appear in Yahoo! Travel, but <br /> there's no reason you can't add it yourself.<br /><br /><br /> To add a custom trip item, browse to the Trip Planner and click the title <br /> of your trip to view the trip page. On the right side of the trip page, <br /> you'll find a box labeled "Add Items to Your Trip." Click the "Add your <br /> own custom items" link, and you'll see a form like the one in Figure 2-74.<br /><br /><br /> Select the trip the item should be included with and then choose a <br /> category for the item. You can choose from Entertainment, Hotel, <br /> Restaurant, Shopping, "Things to do," or Other. Once you've chosen a name <br /> for the item, you can include as few or as many details as you'd like, <br /> including URL, phone number, and address.<br /><br /><br /> Yahoo! Travel also provides a bookmarklet for adding custom items to your <br /> trip. You can find the bookmarklet on the right side of your trip page. To <br /> install, drag the bookmarklet link to your bookmarks. Then, when you're <br /> browsing a site and would like to add it as an item to your trip, click <br /> the bookmarklet and the item name and the URL will be filled in for you.<br /><br /><br /><br /><br /> Figure 2-74. Adding a custom item to an itinerary<br /><br /><br /><br /><br /><br /> 2.25.2. Personalize the Trip<br /><br /><br /> Once you have the hotels, restaurants, and any custom stops listed in your <br /> trip, you can take some time to personalize them by adding a schedule, <br /> categorizing the items, or adding custom notes.<br /><br /><br /> To personalize the trip, browse to the trip page and review the items. <br /> Each item should have three links directly under the listing: "Edit <br /> notes," "Edit tags," and "Add dates." As you click any of these links, a <br /> window will pop up to let you add personal information. For example, click <br /> the "Add dates" link under a restaurant to choose the day of the trip <br /> you'll be visiting and whether it's for Breakfast, Brunch, Lunch, Dinner, <br /> or Other, as shown in Figure 2-75.<br /><br /><br /> Click Update when you're finished, and the item will be scheduled. You can <br /> schedule other items in a similarly intuitive way. Hotels list the <br /> check-in and check-out dates, and attractions can be listed as Morning, <br /> Afternoon, All Day, or Other. You can't list precise times for each item <br /> in the itinerary, but then what trip ever goes exactly as planned?<br /><br /><br /> If you want to add specific times to a particular item, you can add the <br /> times as part of a note. Notes are any arbitrary text you'd like to <br /> associate with an item. This can be anything from information that only <br /> you have about a particular location to warnings about a location that <br /> aren't included in the listing.<br /><br /><br /><br /><br /> Figure 2-75. Assigning a date to a restaurant item<br /><br /><br /><br /><br /><br /> To add another layer of organization to the trip, you can give each item a <br /> set of arbitrary keywords called tags. For example, you might want to tag <br /> every item in a particular city with the name of that city. Or you might <br /> want to tag every activity planned for Friday with the word Friday. People <br /> viewing the itinerary can sort items by tag, so they can zoom in on one <br /> aspect of the trip.<br /><br /><br /> You can also add custom map views to your trip. Browse to your trip page <br /> and click Map View at the top of the page. Adjust the map by zooming in or <br /> out and choosing attractions to list. Once you have a map view you'd like <br /> to share with the group, click the "Save this map" link above the map, as <br /> shown in Figure 2-76.<br /><br /><br /> Once you add the map to your trip, it will be available to anyone viewing <br /> the trip. Plus, you can add notes and tags to the map to add detailed <br /> explanation or group the map with other items in your trip.<br /><br /><br /> As you can see, the Yahoo! Travel Trip Planner provides a way for you to <br /> be your own travel agent and share detailed plans with others. Plus, each <br /> stop in the itinerary links to web sites with more information, giving <br /> your travel mates the ability to do their own research about areas they'll <br /> be visiting. And storing the travel plans on Yahoo! means the itinerary <br /> will be available anywhere there's an Internet connection.<br /><br /><br /><br /><br /> Figure 2-76. Yahoo! Trip Map View with the "Save this map" link<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 47. Shop Intelligently<br /><br /><br /><br /><br /><br /> Use Yahoo! Shopping to find and compare products across the Web.<br /><br /><br /> Shopping is more of an art than a science. Finding the right item at the <br /> right price involves a bit of intuition and luck. But there's no reason <br /> you can't bring a bit of science into your shopping habits to help you <br /> find, compare, and buy. Imagine you're interested in purchasing a portable <br /> music player, but you're not sure which to buy or where to buy it. You <br /> could physically drive to your local electronics stores and browse, but <br /> you'd miss out on the benefit of choices beyond what they have in stock <br /> and you wouldn't have instant access to information about each of the <br /> products and their differences. You could browse to your favorite online <br /> stores, but you'd only find prices at each individual outlet.<br /><br /><br /> Just as Yahoo! brings together thousands of news sources at Yahoo! News <br /> (http://news.yahoo.com/) and millions of web pages at Yahoo! Search <br /> (http://search.yahoo.com/), Yahoo! Shopping (http://shopping.yahoo.com/) <br /> indexes merchants across the Web to find prices for thousands of products. <br /> Instead of typing portable music player into Yahoo! Search and sifting <br /> through hundreds of results to find online stores, you can search or <br /> browse Yahoo! Shopping and see prices at merchants that Yahoo! has <br /> approved. In addition to finding and comparing prices, you can add items <br /> from multiple merchants to a wish list and compare product features side <br /> by side.<br /><br /><br /> 2.26.1. Find<br /><br /><br /> There are several ways to find products at Yahoo! Shopping, whether you <br /> know exactly what you're looking for, want to browse from products <br /> available, or want suggestions for special occasions.<br /><br /><br /> 2.26.1.1. Searching.<br /><br /><br /> Type portable music player into the search form at <br /> http://shopping.yahoo.com/, and each result will be a specific product. <br /> You can click each result to see more product details and compare prices <br /> across different merchants, or you can select several results and compare <br /> differences in the product features. The search form is also handy if you <br /> already know the product you're looking for.<br /><br /><br /><br /><br /> You can click the Advanced Search link next to the search form <br /> (or point your browser to <br /> http://shopping.yahoo.com/search/advanced) to narrow your <br /> search results to a specific product category or price range.<br /><br /><br /><br /><br /><br /><br /> 2.26.1.2. Browsing.<br /><br /><br /> If you don't know quite what you're looking for, you can use the <br /> categories on the left side of the Yahoo! Shopping home page to narrow <br /> your search. Or browse directly to <br /> http://shopping.yahoo.com/directory.html to see a list of all categories, <br /> as shown in Figure 2-77.<br /><br /><br /><br /><br /> Figure 2-77. Browsing categories at Yahoo! Shopping<br /><br /><br /><br /><br /><br /> For example, you can browse to the category Electronics and select the <br /> subcategory MP3 Players to see links with more information about players, <br /> lists by brand, and a list of the top five players. Browsing for products <br /> gives you a few more options along the way than simply viewing a list of <br /> individual products.<br /><br /><br /> 2.26.1.3. Gift Finder.<br /><br /><br /> When you're shopping for someone else, it can be hard to come up with <br /> ideas. Yahoo! Gift Finder (http://shopping.yahoo.com/giftfinder) will give <br /> you product suggestions based on information you provide in a short <br /> questionnaire. Browse to the Gift Finder, choose an occasion (birthday, <br /> wedding, specific holiday, etc.), and then answer several questions about <br /> the gift recipient. The Gift Finder will give you a series of options to <br /> look through.<br /><br /><br /> 2.26.1.4. SmartSort.<br /><br /><br /> SmartSort (http://shopping.yahoo.com/smartsort) is a tool that lets you <br /> specify the importance of different product features and returns a list <br /> based on your criteria. At the time of this writing, SmartSort supports <br /> only electronic gadgets, but it can help you decide which gadgets to buy. <br /> Say you're interested in digital cameras and are most concerned about a <br /> compact size. You can specify that criteria in SmartSort and see a list of <br /> possibilities, as shown in Figure 2-78.<br /><br /><br /><br /><br /> Figure 2-78. Comparing digital cameras with SmartSort<br /><br /><br /><br /><br /><br /> Internet Explorer users will see sliders at the top of the SmartSort page <br /> that they can adjust to affect the results, while users of other browsers <br /> will see a series of radio buttons.<br /><br /><br /> 2.26.1.5. Product feeds.<br /><br /><br /> Yahoo! also provides RSS for various product categories, and you can see a <br /> full list of feeds available at http://shopping.yahoo.com/rss. If you're <br /> not quite ready to buy a portable music player today but want to keep your <br /> eye on the market, you can subscribe to the MP3 Player feed and see new <br /> products in your newsreader or at My Yahoo!.<br /><br /><br /> 2.26.2. Compare<br /><br /><br /> As you're browsing or searching products, you can check the Compare box <br /> next to many products and then click the "Compare side by side" button at <br /> the bottom of the page. This will show you the selected products together <br /> on one page, with a list of features compared. Figure 2-79 shows two <br /> digital cameras side by side.<br /><br /><br /><br /><br /> Figure 2-79. Comparing two digital cameras<br /><br /><br /><br /><br /><br /> Once you've found a product you're interested in, you can click the <br /> product title to visit the product detail page. Figure 2-80 shows a <br /> product detail page for a 20GB iPod.<br /><br /><br /><br /><br /> Figure 2-80. An iPod product detail page<br /><br /><br /><br /><br /><br /> The product detail page provides links to more information, such as <br /> specifications and reviews. But most importantly, it prices across <br /> different merchants. You can scan the page to find the lowest price and <br /> view merchant ratings.<br /><br /><br /><br /><br /> Merchant ratings at Yahoo! Shopping are based on the reviews <br /> of Yahoo! users. If you've had a positive or negative <br /> experience with a merchant listed at Yahoo! Shopping, you can <br /> click the "Write a review" link to add your own rating and <br /> comments for that merchant.<br /><br /><br /><br /><br /><br /><br /> When you're ready to buy, click the Buying Info button to leave the Yahoo! <br /> Shopping site and visit the merchant's page for that product. From there, <br /> you can follow that merchant's procedure for buying the item.<br /><br /><br /> 2.26.3. Save and Share<br /><br /><br /> Another unique feature of Yahoo! Shopping is the ability to save products <br /> from many different merchants to a single shopping list. Instead of <br /> maintaining multiple wish lists across different sites, you can store the <br /> items at Yahoo! Shopping by clicking the "Save and Share" link next to any <br /> product listing. Once an item is on your wish list, you can keep tabs on <br /> the price and add your own notes about the product, shown in Figure 2-81.<br /><br /><br /><br /><br /> Figure 2-81. Saving products from different merchants to a wish list<br /><br /><br /><br /><br /><br /> And, of course, it wouldn't be a wish list if you couldn't share it with <br /> others. Click the "Email your listings" link at the top of the page to <br /> send an email like the one shown in Figure 2-82.<br /><br /><br /> Sharing exactly what you want with others means you can get exactly what <br /> you want the next time a special occasion rolls around.<br /><br /><br /> Yahoo! Shopping won't make the art of finding the perfect item obsolete, <br /> but it can help you make informed choices by showing you what's available, <br /> by comparing the product with similar items, and by letting you share the <br /> products you've found with others.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 48. Visualize Your Music Collection<br /><br /><br /><br /><br /><br /> Use the Yahoo! Music Engine API to find out which artists appear most <br /> often in your collection.<br /><br /><br /> Visualizing an entire music collection has never been easy. Whether the <br /> music is in stacks of vinyl records or in racks full of CDs, it's tough to <br /> get a picture of all of the artists, albums, and genres that are so unique <br /> to each of us. Moving music from the physical world to the digital world <br /> of computers has helped, because digital formats can store information <br /> about albums and artists that can be extracted and analyzed.<br /><br /><br /><br /><br /> Figure 2-82. Yahoo! Shopping wish list email<br /><br /><br /><br /><br /><br /> This hack helps you visualize your virtual music collection by showing you <br /> a list of artists in different font sizes: the larger the font, the more <br /> tracks you have by that artist. With this approach, you can see at a <br /> glance whether you have more tracks by Kraftwerk or The Propellerheads, <br /> and which artists you have the most tracks from.<br /><br /><br /> Using different-sized fonts to represent popularity is sometimes called a <br /> tag map and was pioneered by the photo-sharing site Flickr [Hack #67].<br /><br /><br /><br /><br /> You can see the most popular photo tags on Flickr in this <br /> format at http://www.flickr.com/photos/tags.<br /><br /><br /><br /><br /><br /><br /> This hack creates a tag maplike interface for the artists in your music <br /> collection by tapping into the Yahoo! Music Engine.<br /><br /><br /> 2.27.1. Yahoo! Music Engine<br /><br /><br /> The Yahoo! Music Engine (YME) is a free music player for Windows. It's <br /> available for download at http://music.yahoo.com/musicengine. If you <br /> already use WinAmp or iTunes, you'll find the YME very familiar, and the <br /> controls should be intuitive. You can use it alongside your current player <br /> or use YME exclusively. If you already have a collection of music files on <br /> your computer, you can import them to YME by choosing File "Add a Folder <br /> to My Music." Once your music has been imported, you can click My Music on <br /> the left side and see all of the tracks in your collection.<br /><br /><br /> One feature that separates YME from the pack is its plug-in architecture <br /> operating behind the scenes. A plug-in is a bit of code that adds a <br /> feature to an application that wasn't originally built into the system. <br /> Yahoo! has made plug-ins fairly easy to write by making their API <br /> available through Java-Script. And because YME contains a web browser, <br /> it's possible to write a web page that can control and interact with YME <br /> through scripting.<br /><br /><br /> If you're familiar with writing JavaScript for web pages, you'll find <br /> writing YME plug-ins fairly painless. In fact, Yahoo! has a page <br /> specifically for web developers, explaining how to use HTML and JavaScript <br /> to write plug-ins for YME <br /> (http://mep.music.yahoo.com/plugins/docs/webquickstart_page.html).<br /><br /><br /> The following code is a sample plug-in that you can build and install for <br /> YME that helps you visualize the artists in your music collection by <br /> popularity.<br /><br /><br /> 2.27.2. The Code<br /><br /><br /> The code for this plug-in was written by Dave Brown at Yahoo! and is a <br /> standard HTML page with JavaScript. The script queries the YME database, <br /> gathering a list of the artists in your library. From there, the script <br /> counts how many tracks you have from each artist and displays the artist <br /> names in the appropriate font size.<br /><br /><br /> To get started, save the following code to a file called artistCloud.html:<br /><br /><br /> <html><br /> <head><br /> <style><br /> body {<br /> background-color:#fff;<br /> font-family:Tahoma, Verdana, Arial;<br /> color:#354251;<br /> }<br /> .tag {<br /> margin-bottom: 10px;<br /> padding: 5px;<br /> }<br /> </style><br /> </head><br /><br /><br /> <body><br /><br /><br /> <script><br /> // This YME plug-in looks through a music library and prints the names<br /> // of the artists in a font which is proportional to the number of songs<br /> // which are by that artist in the library.<br /> //<br /> // by Dave Brown at Yahoo!<br /><br /><br /> var minFontSize = 8; // minimum font size in pixels<br /> var maxFontSize = 24; // max font size in pixels<br /> var METADATA_ARTIST = 0; // you should really get this constant from <br />yme.js<br /> // available from the Developer SDK.<br /> // Obtain YME's media database which holds the library of tracks:<br /> var mediaDB = window.external.MediaDatabase;<br /><br /><br /> // Get the string name of the artist field, which is used in our database <br /><br /><br /><br /> queries:<br /> var artistFieldName = mediaDB.Description.GetPredefinedName(METADATA_<br /><br /><br /><br /> ARTIST);<br /><br /><br /> // Get a listing of all unique artist names:<br /> var artistNames = mediaDB.GetUniqueIndexValues(artistFieldName);<br /> var numArtistNames = artistNames.Count;<br /><br /><br /> // For each artist, get a count of how many tracks are by that artist,<br /> // and store it in our array…like a histogram.<br /> // Also store the maximum value we encounter, so we can normalize <br /><br /><br /><br /> everything.<br /> // (We do normalization because some people may have a large variance of<br /> // tracks per artist, and others a small variance.)<br /><br /><br /> var tracksPerArtist = new Array(numArtistNames);<br /> var maxTracksPerArtist = 0;<br /><br /><br /> for ( i = 0; i < numArtistNames; ++i )<br /> {<br /> // Get the # of objects in the database for each artist:<br /> var objectsForArtist = mediaDB.IndexQuery( artistFieldName, <br /><br /><br /><br /> artistNames(i) );<br /><br /><br /> // Remember this…<br /> tracksPerArtist[i] = objectsForArtist.Count;<br /><br /><br /> // Do we have a new max?<br /> if ( tracksPerArtist[i] > maxTracksPerArtist )<br /> maxTracksPerArtist = tracksPerArtist[i];<br /> }<br /><br /><br /> // Print the artists…<br /> for ( i = 0; i < numArtistNames; ++i )<br /> {<br /> // Set the font size<br /> var fontSize = minFontSize + Math.floor( maxFontSize * <br /><br /><br /><br /> (tracksPerArtist[i] / maxTracksPerArtist) );<br /><br /><br /> // Print the artist:<br /> document.writeln( "<span class='tag' style='font-size:" + fontSize + <br /><br /><br /><br /> "px'>" + artistNames(i) + "</span>" );<br /> }<br /> }<br /> </script><br /> <script type="text/javascript" src="https://www.blogger.com/static/v1/common/js/545917451-csitail.js"></script> <script type="text/javascript">BLOG_initCsi('classic_blogspot');</script></body><br /> </html><br /><br /><br /><br /><br /> 2.27.3. Running the Hack<br /><br /><br /> Browse to the directory where you installed YME (usually C:\Program <br /> Files\Yahoo!\ Yahoo! Music Engine) and save artistCloud.html to the <br /> Plugins directory.<br /><br /><br /> All YME plug-ins are added via the Windows Registry, so you'll need to add <br /> a Registry key that defines your plug-in. The following Registry file code <br /> will add the necessary information to your Registry. Create a file called <br /> YME_artistCloud.reg with the following code and be sure to add the correct <br /> path to your YME installation:<br /><br /><br /> Windows Registry Editor Version 5.00<br /><br /><br /> [HKEY_LOCAL_MACHINE\SOFTWARE\Yahoo\YMP\Plugins\ArtistCloud]<br /> "Enabled"=dword:00000001<br /> "Type"=dword:00000001<br /> "URL"="file://C:\\path to YME\\Plugins\\artistCloud.html"<br /> "Name"="ArtistCloud"<br /> "Description"="Display a list of artists as a tag cloud."<br /> "BitmapFile"="C:\\path to YME\\Plugins\\artistCloud.bmp"<br /><br /><br /><br /><br /> Note that there's a setting for BitmapFile that points to artistCloud.bmp, <br /> but the file won't exist unless you create it. BitmapFile specifies a 16 x <br /> 16 pixel icon for a plug-in, and you'll need to create your own icon and <br /> throw it into the Plugins directory if you want a visual ID for your <br /> plug-in.<br /><br /><br /> Save the Registry file and double-click the file to add the Registry <br /> settings. You'll need to completely restart YME, so click its icon in the <br /> system tray and choose Exit. Once it's restarted, you should see the <br /> option ArtistCloud in the right column. Click it, and you'll see a list of <br /> your artists like the one shown in Figure 2-83.<br /><br /><br /> The ArtistCloud plug-in gives you a new way to visualize your music <br /> collection, and you can see at a glance which artists created the most <br /> tracks in your collection.<br /><br /><br /> 2.27.4. Hacking the Hack<br /><br /><br /> By slightly tweaking the script, you can create a similar tag cloud for <br /> the various genres in your collection. Create a copy of artistCloud.html <br /> called genreCloud.html. Edit it to change the value of METADATA_ARTIST to <br /> 9, like so:<br /><br /><br /> var METADATA_ARTIST = 9;<br /><br /><br /><br /><br /> In reality, the number 9 refers to the API variable METADATA_GENRE, and <br /> this little tweak is fast, but it doesn't make for readable code. Copy the <br /> new file to the YME Plugins directory.<br /><br /><br /><br /><br /> If you want to see a list of all the API variables and their <br /> values, take a look at <br /> http://plugins.yme.music.yahoo.com/plugins/docs/yme.js.<br /><br /><br /><br /><br /><br /><br /><br /><br /> Figure 2-83. A cloud of artists in Yahoo! Music Engine<br /><br /><br /><br /><br /><br /> Likewise, copy YME_artistCloud.reg and edit the file so that every <br /> reference to ArtistCloud becomes GenreCloud. Name the file <br /> YME_genreCloud.reg and run the file. Restart YME, and you should see the <br /> GenreCloud plug-in, which you can click to see if Rock beats out Country <br /> in your collection, and if Electronic music is more prevalent than Punk.<br /><br /><br /> 2.27.5. TraxStats<br /><br /><br /> As you might expect, a number of people are creating plug-ins and sharing <br /> them with the world. Yahoo! has an official unofficial site for sharing <br /> plug-ins at http://plugins.yme.music.yahoo.com/. One of the plug-ins <br /> available at the site, TraxStats by Larry Wang <br /> (http://plugins.yme.music.yahoo.com/archives/2005/03/traxstats.html), can <br /> help you gather statistics about your collection.<br /><br /><br /> Once you download and install the plug-in, you can get some quick reports <br /> about your collection. Figure 2-84 shows the number of songs for each <br /> artist in a list.<br /><br /><br /> YME is making plug-in development easier for developers and designers, and <br /> this might bring about entirely new ways for us to visualize our personal <br /> music collections.<br /><br /><br /><br /><br /> Figure 2-84. Viewing the number of songs per artist with TraxStats<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 49. Take Yahoo! on the Go<br /><br /><br /><br /><br /><br /> Yahoo! Mobile lets you take much of the power of Yahoo! with you.<br /><br /><br /> Yahoo! Mobile gives you a subset of Yahoo! features for devices with small <br /> form factors such as your mobile phone or personal digital assistant <br /> (PDA). Yahoo! Mobile is optimized for relatively slow wireless data <br /> connections similar to analog modem speeds. Many phones already provide a <br /> link to Yahoo! Mobile in the phone's browser, but if you don't spot a <br /> link, you can point your phone to http://mobile.yahoo.com/.<br /><br /><br /> 2.28.1. Yahoo! Lite<br /><br /><br /> When you browse to Yahoo! Mobile on your phone, you'll find a simplified <br /> home page with many familiar Yahoo! features, such as Search, News, <br /> Weather, Sports, and Movies. You'll also see a link that allows you to log <br /> in with your Yahoo! ID and password. Once you log in, you'll see <br /> personalized options like the ones shown in Figure 2-85.<br /><br /><br /> If you have Yahoo! Mail, Yahoo! Finance portfolios, Yahoo! Movies theater <br /> preferences, and other customizations at the Yahoo! web site, you'll find <br /> them on Yahoo! Mobile as well.<br /><br /><br /> Some mobile device browsers (such as the Microsoft Internet Explorer for <br /> Windows Mobile PCs and Smartphone devices) do not store the Yahoo web <br /> cookies that allow a login session to persist when you revisit the Yahoo! <br /> Mobile page again. If this is the case for your PDA or phone, you might <br /> want to consider choosing a password that can be quickly entered using <br /> whatever data input options you have (e.g., phone keypad, thumb keyboard, <br /> handwriting recognition, etc.). Always keep the security implications for <br /> your account [Hack #3] in mind.<br /><br /><br /><br /><br /> Figure 2-85. Yahoo! Mobile portal page<br /><br /><br /><br /><br /><br /> Yahoo! Mobile lets you choose the amount of graphics that appears on your <br /> mobile device. Figure 2-85 shows a screen from a Microsoft Windows Mobile <br /> Smartphone device with the Lite Graphics option turned on. Use this <br /> setting if you have a relatively slow wireless data connection such as <br /> GPRS, which is about the same speed as some analog 56Kbps modem <br /> connections. Scroll to the bottom of the Yahoo! Mobile home page on your <br /> phone to change the graphics settings.<br /><br /><br /> 2.28.2. Yahoo! Mobile Features<br /><br /><br /> Any of the options on the Yahoo! Mobile home page can be selected by <br /> either scrolling through the list or pressing the number on the keypad <br /> associated with an option. Here's a closer look at each feature and how it <br /> differs from what you'll find on the more familiar Yahoo! web site. Keep <br /> in mind that some features listed here aren't available for all mobile <br /> devices. You can find out which services are available for your phone or <br /> PDA by registering the device via your computer's web browser at the <br /> Yahoo! Mobile web site (http://mobile.yahoo.com/).<br /><br /><br /><br /><br /> Mail<br /><br /><br /> Yahoo! Mail can display up to 200 messages on a single web page when used <br /> with a conventional desktop browser. However, Yahoo! Mobile Mail is <br /> limited to 10 messages per screen, numbered 1 through 0 (0 is used for the <br /> 10th message). The email text body is also truncated and might require <br /> several screen updates to display a long email message. You can use the <br /> Yahoo! Address Book to retrieve email addresses when composing an email <br /> message.<br /><br /><br /><br /><br /> If the web-based email doesn't fit your work style, <br /> subscribing to the Yahoo! Plus premium service allows you to <br /> use your mobile device's POP3 email facility to retrieve <br /> Yahoo! Mail.<br /><br /><br /><br /><br /><br /><br /><br /><br /> Messenger<br /><br /><br /> The Yahoo! Messenger option works only on mobile devices that directly <br /> support it. Choosing it on an unsupported device such as a Microsoft <br /> Windows Mobilebased Pocket PC results in a blank screen.<br /><br /><br /><br /><br /> Search<br /><br /><br /> The Yahoo! Mobile Search page gives you a subset of search types, <br /> including Local, Images, and Web searches. The Video, Directory, News, and <br /> Shopping searches found on the desktop are not provided as search options.<br /><br /><br /><br /><br /> Games<br /><br /><br /> Six low-resolution (mostly text) games are available: Wordaholic, <br /> Blackjack, Video Poker, Hangman, 4-In-A-Row, and Dice Slider.<br /><br /><br /><br /><br /> News<br /><br /><br /> The News article selection is as comprehensive as the desktop Yahoo! News <br /> option. Thumbnail photographs might be presented along with the text. <br /> Selecting the thumbnail photo displays a larger version of the photograph.<br /><br /><br /><br /><br /> Sports<br /><br /><br /> Sports news and scores are provided in extremely brief forms. The scores <br /> for a particular game might provide only the score itself and not the more <br /> detailed team and individual statistics that many fans crave.<br /><br /><br /><br /><br /> Finance<br /><br /><br /> The portfolios you set up in a desktop browser all show up in Yahoo! <br /> Mobile. Drilling down to a specific company results in basic trade <br /> information, such as range and volume. You can also get company-specific <br /> news and a graphic trading chart for the day.<br /><br /><br /><br /><br /> Weather<br /><br /><br /> A brief version of your local weather is shown and linked at the top level <br /> of Yahoo! Mobile. Selecting that link gives you more detailed weather <br /> information. The My Weather page shows you eight of your selected cities <br /> at a time.<br /><br /><br /><br /><br /> Movies<br /><br /><br /> The Movies option shows you a list of current popular movies. Selecting a <br /> movie link leads you to a list of schedules of local theaters showing the <br /> movie as well as a summary of the movie itself.<br /><br /><br /><br /><br /> Driving Directions<br /><br /><br /> This feature has a default starting address (your home, for example) and <br /> lets you fill in a destination address. The driving directions are <br /> provided only in text. Graphic maps are not provided.<br /><br /><br /><br /><br /> Address Book<br /><br /><br /> The Address Book contains all the addresses found in the desktop browser <br /> version. One added bonus for phone users is that telephone numbers are <br /> presented using the tel: tag. If your phone browser supports it, selecting <br /> the web-linked telephone number initiates a voice call to that number.<br /><br /><br /><br /><br /> Calendar<br /><br /><br /> The Calendar shows you tasks and events. The events list can be viewed by <br /> day, week, or month.<br /><br /><br /> The Yahoo! Mobile Search screen in Figure 2-86 shows you how Yahoo! <br /> reformats the screen for mobile devices. This simplified view lets you <br /> work quickly on a small screen.<br /><br /><br /><br /><br /> Figure 2-86. Yahoo! Mobile Search<br /><br /><br /><br /><br /><br /> If you want to browse the Yahoo! Mobile site in a web browser on your <br /> desktop before you try it on your phone, visit http://wap.oa.yahoo.com/. <br /> This will give you a chance to try out the features with a quick <br /> connection before you need them in the wild. You won't find everything <br /> from Yahoo! on your mobile device, but you'll get the basics with Yahoo! <br /> Mobile. Many times when you're traveling, that's all you need.<br /><br /><br /> Todd Ogasawara<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 50. Stay Connected with Yahoo! Alerts<br /><br /><br /><br /><br /><br /> Yahoo! Alerts send information that's important to you, when and where you <br /> need it.<br /><br /><br /> Alerts are small text messages sent from Yahoo! that can let you know <br /> everything from how much snow fell at your favorite ski resort last night, <br /> to how a particular stock is faring in the middle of the day, to who was <br /> the winner at the end of a ballgame. The key is that alerts keep you <br /> up-to-date with information whether you're sitting in front of your <br /> computer or out in the world.<br /><br /><br /> To start receiving alerts, all you have to do is let Yahoo! know what <br /> you'd like to be alerted about and how you'd like to receive the alert: <br /> via email, instant message, or mobile device.<br /><br /><br /> 2.29.1. Setting up Alert Devices<br /><br /><br /> The simplest way to start receiving alerts is via any email address, <br /> including your Yahoo! Mail address. When you create an alert, specify <br /> Email as the delivery method and choose one of the addresses associated <br /> with your Yahoo! ID.<br /><br /><br /><br /><br /> Need to add or change an email address associated with your <br /> Yahoo! ID? Browse to http://edit.yahoo.com/config/eval_profile <br /> and log in to add or remove email addresses from your account.<br /><br /><br /><br /><br /><br /><br /> With a bit more work, you can also receive Yahoo! Alerts on a cell phone <br /> or pager that supports SMS messages. Before you can set a mobile alert, <br /> you'll need to visit http://mobile.yahoo.com/ to associate a mobile device <br /> with your Yahoo! ID. From Yahoo! Mobile, you can find out if your device <br /> can accept alerts and verify your device so that Yahoo! knows you've <br /> authorized it to send alerts. Once set up, you can choose Mobile as the <br /> delivery method for an alert. Figure 2-87 shows a weather alert for <br /> Corvallis, Oregon, sent to a mobile device.<br /><br /><br /><br /><br /> Figure 2-87. A mobile weather alert for Corvallis, Oregon<br /><br /><br /><br /><br /><br /> You can also receive some alerts via Yahoo! Instant Messenger. Download <br /> Yahoo! Instant Messenger at http://messenger.yahoo.com/, set up an <br /> account, and choose Messenger as the delivery method for an alert. Then, <br /> any Instant Messenger alerts will pop up on your screen while you're at <br /> the computer.<br /><br /><br /> Many alerts also let you choose multiple delivery methods. So, if you have <br /> all three device types set up, you could set an alert to give you breaking <br /> news from the Associated Press via email, instant messenger, and your <br /> pager!<br /><br /><br /> 2.29.2. Setting Alerts<br /><br /><br /> As you're browsing around Yahoo! sites such as Yahoo! Travel, Yahoo! <br /> Shopping, or Yahoo! Finance, you might see a ringing bell icon and a Set <br /> Alert link, as shown in Figure 2-88.<br /><br /><br /><br /><br /> Figure 2-88. Set Alert link at Yahoo! Finance<br /><br /><br /><br /><br /><br /> Clicking this link is the fastest way to set an alert related to the <br /> content you're viewing. If you're browsing the San Francisco section of <br /> Yahoo! Travel, you can simply click Set Alert to be notified of the best <br /> travel fares to the city.<br /><br /><br /> You can also set up alerts by browsing to http://alerts.yahoo.com/ and <br /> looking through the alerts directory. Here's a sampling of the available <br /> alerts:<br /><br /><br /><br /><br /> Auctions<br /><br /><br /> Select an alert based on the category of auction entry, the seller, or a <br /> keyword. Searches Yahoo! Auctions and can send updates immediately or <br /> summarize once or twice daily.<br /><br /><br /><br /><br /> Avatars<br /><br /><br /> Get updates on new clothes, backgrounds, or any new items for your Yahoo! <br /> Instant Messenger avatar.<br /><br /><br /><br /><br /> Best Fares<br /><br /><br /> Select your favorite route and be alerted when the fare drops or increases <br /> by $25 or more from the current fareor if the price goes below a selected <br /> amount.<br /><br /><br /><br /><br /> Breaking News<br /><br /><br /> Choose between standard Associated Press alerts with frequent updates or <br /> the AP Bulletin, which focuses on the biggest breaking news stories.<br /><br /><br /><br /><br /> Health News<br /><br /><br /> Use these alerts to get health news for words or phrases that you specify. <br /> For example, a diabetes alert will send summaries of new diabetes-related <br /> articles.<br /><br /><br /><br /><br /> Horoscopes<br /><br /><br /> Set your astrological sign and a time to receive your daily horoscope.<br /><br /><br /><br /><br /> Yahoo! Mail<br /><br /><br /> Receive an alert when new mail arrives at your Yahoo! Mail account <br /> (available for wireless devices only).<br /><br /><br /><br /><br /> Missing Children<br /><br /><br /> Enter your Zip Code, and you'll be notified of any Missing Children Alerts <br /> issued within your area. You might be able to help if you have any <br /> information.<br /><br /><br /><br /><br /> News<br /><br /><br /> Subscribe to breaking news alerts, keyword news alerts, and top news <br /> within selected categories.<br /><br /><br /><br /><br /> Snowfall<br /><br /><br /> Receive notification when snow levels at your favorite resorts across the <br /> world reach a specified minimum. You never know when you might need to <br /> take off and ski!<br /><br /><br /><br /><br /> Sports<br /><br /><br /> Set your favorite teams and get updates during games, or scores when the <br /> games end.<br /><br /><br /><br /><br /> Stock Alerts<br /><br /><br /> Receive daily updates of stock levels for your favorite stocks, or receive <br /> notice when they reach a specified numeric or percentage change.<br /><br /><br /><br /><br /> Weather<br /><br /><br /> Receive daily updates of weather within a specified Zip Code at a <br /> specified time.<br /><br /><br /><br /><br /> Yahoo! 360<br /><br /><br /> Receive an alert when someone sends you a message or adds you as a friend <br /> at Yahoo! 360.<br /><br /><br /> 2.29.3. Modifying Alerts<br /><br /><br /> Once set, any alert can be modified, temporarily paused, or removed. You <br /> can see all of the alerts you've set by browsing to <br /> http://alerts.yahoo.com/ and clicking the My Alerts tab. Each alert will <br /> show the type, activated status, and delivery method, as shown in Figure <br /> 2-89.<br /><br /><br /><br /><br /> Figure 2-89. My Alerts page at Yahoo! Alerts<br /><br /><br /><br /><br /><br /> To change any of the options you've set for an alert, click the pencil <br /> icon. To temporarily stop receiving an alert, click the On or Off status <br /> button to change the status. If an alert is listed as Off, you won't <br /> receive the alert. Clicking the trash icon and confirming the delete will <br /> completely remove an existing alert; you'll stop receiving the alert and <br /> you'll need to go through the alert setup process from the beginning if <br /> you change your mind and want to receive the deleted alert again in the <br /> future.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Chapter 3. Communicating<br /><br /><br /><br /> Section 3.1. Hacks 5167: Introduction <br /><br /><br /> Hack 51. Navigate Yahoo! Mail <br /><br /><br /> Hack 52. Manage Yahoo! Mail <br /><br /><br /> Hack 53. Create Yahoo! Mail Macros <br /><br /><br /> Hack 54. Read All Your Email in One Place <br /><br /><br /> Hack 55. Read Yahoo! Mail in Your Preferred Email Client <br /><br /><br /> Hack 56. Manage and Share Your Schedule <br /><br /><br /> Hack 57. Add Contacts to Your Yahoo! Address Book <br /><br /><br /> Hack 58. Map Yahoo! Address Book Contacts <br /><br /><br /> Hack 59. Discuss, Share, and Collaborate with Others <br /><br /><br /> Hack 60. Archive Yahoo! Groups Messages with yahoo2mbox <br /><br /><br /> Hack 61. Explore Your Social Networks <br /><br /><br /> Hack 62. Import an Existing Blogroll to Yahoo! 360 <br /><br /><br /> Hack 63. Add an API to Your Yahoo! 360 Blog <br /><br /><br /> Hack 64. Create a Yahoo! Avatar <br /><br /><br /> Hack 65. Add a Content Tab to Yahoo! Messenger <br /><br /><br /> Hack 66. Send Instant Messages Beyond Yahoo! <br /><br /><br /> Hack 67. Store, Sort, and Share Your Photos <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> 3.1. Hacks 5167: Introduction<br /><br /><br /> Over 55 million people around the world have signed up and sent email with <br /> Yahoo! Mail. Even if you don't use Yahoo! Mail yourself, the chances are <br /> very good that you've received email from a friend, family member, or <br /> coworker who uses Yahoo! Mail. By making email accessible through a web <br /> browser, Yahoo! has given millions the ability to send and receive email <br /> without configuring a client application or knowing what a mail server is. <br /> This chapter shows how to manage [Hack #52] and navigate [Hack #51] Yahoo! <br /> Mail more effectively and how to use Yahoo! Mail as a universal client <br /> [Hack #54] when you need access to other email accounts.<br /><br /><br /> In addition to Yahoo! Mail, Yahoo! provides a number of other tools to <br /> connect with friends, meet new people, and collaborate online. Yahoo! <br /> Groups [Hack #59] provides a way to discuss topics and plan with others, <br /> and Yahoo! 360 [Hack #61] keeps you in touch with friends and family while <br /> introducing you to friends of friends. Yahoo! Messenger lets you have <br /> real-time conversations with your friends, and adding avatars [Hack #64] <br /> adds a new dimension to your discussions. And the photo-sharing service <br /> Flickr [Hack #67] allows communities to form around sharing images.<br /><br /><br /> Whether or not you're one of the millions already using Yahoo! tools to <br /> connect with others on a daily basis, you're probably already <br /> participating in some conversations using Yahoo!, and the hacks in this <br /> chapter will show you how to dig a bit deeper into those tools.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 51. Navigate Yahoo! Mail<br /><br /><br /><br /><br /><br /> Find your way around the Yahoo! Mail interface, and speed up common tasks <br /> with keyboard shortcuts.<br /><br /><br /> Yahoo! Mail has been a runaway success because it's easy to use. Web-based <br /> email gives users an account they can access from any machine with an <br /> Internet connection. You don't have to know how to configure an email <br /> client such as Outlook to use Yahoo! Mail; you just need to know how to <br /> use a browser. You won't have any trouble using Yahoo! Mail to send <br /> messages across the Internet, but by taking a few minutes to learn how <br /> Yahoo! Mail is organized, you might find ways to speed up the way you send <br /> email.<br /><br /><br /> 3.2.1. Yahoo! Mail Layout<br /><br /><br /> You can get to your Yahoo! Mail by browsing to http://mail.yahoo.com/. You <br /> can also type mail! into any Yahoo! Search form to go directly to Yahoo! <br /> Mail. This even works from external search forms, such as the Firefox <br /> Quick Search Box [Hack #13].<br /><br /><br /><br /><br /> In addition to using the mail! shortcut, you can get to most <br /> Yahoo! properties by typing the property's name into a Yahoo! <br /> search form and adding an exclamation point. Try others, such <br /> as directory!, finance!, tv!, and movies!.<br /><br /><br /><br /><br /><br /><br /> Yahoo! Mail is really four applications in one, and here's a quick look at <br /> how you can use each of them:<br /><br /><br /><br /><br /> Mail<br /><br /><br /> As you'd expect, this is the heart of the application, where you can read <br /> and send email via your web browser.<br /><br /><br /><br /><br /> Addresses<br /><br /><br /> This is your personal address book, where you can store not only a contact <br /> name and email address, but also phone numbers, home and work addresses, <br /> birthdays and anniversaries, and free-form notes about each contact. You <br /> can access your address book directly at http://address.yahoo.com/.<br /><br /><br /><br /><br /> Calendar<br /><br /><br /> This is a space where you can plan your schedule by adding events and <br /> tasks to a calendar. You can view the calendar by week, month, or year, <br /> and see your tasks as a to-do list. You can also share your calendar with <br /> others. Your calendar is available directly at http://calendar.yahoo.com/.<br /><br /><br /><br /><br /> Notepad<br /><br /><br /> Your notepad is a place for simple text notes to yourself. If you have <br /> some class notes, a shopping list, or any sort of simple text, your Yahoo! <br /> notepad will make it accessible from any computer with Internet access. <br /> You can add notes to your notepad directly at http://notepad.yahoo.com/.<br /><br /><br /> You can access any of these four applications from the tabs in the Yahoo! <br /> Mail navigation bar shown in Figure 3-1.<br /><br /><br /> This navigation bar is available toward the top of every Yahoo! Mail page. <br /> In addition to the navigation tabs, it shows you the path to checking and <br /> composing email, searching your email, and editing your preferences with <br /> the Mail Options link in the upper-right corner. Be sure to note the <br /> location of the Mail Options link, because it's the key to setting your <br /> preferences.<br /><br /><br /><br /><br /> Figure 3-1. The Yahoo! Mail navigation bar<br /><br /><br /><br /><br /><br /> 3.2.2. Keyboard Shortcuts<br /><br /><br /> If you want to give your mouse muscles a break, you can also navigate with <br /> a few built-in keyboard shortcuts. These shortcuts are simply combinations <br /> of keys you type to move around within Yahoo! Mail. For example, say <br /> you're looking through events in your calendar and you realize you need to <br /> fire off an emergency email related to something you've found. You could <br /> click the Mail tab and then the Compose button from the navigation bar. Or <br /> you could type Ctrl-Shift-P on the keyboard, and you'll find yourself at <br /> the new mail form.<br /><br /><br /> It takes a bit of keyboard dexterity to hold both the Ctrl and Shift <br /> buttons down while pressing a letter. But once you get the hang of it, you <br /> can speed up some of the most common tasks:<br /><br /><br /><br /><br /> Check mail<br /><br /><br /> Ctrl-Shift-C<br /><br /><br /><br /><br /> Compose new mail<br /><br /><br /> Ctrl-Shift-P<br /><br /><br /><br /><br /> View folders<br /><br /><br /> Ctrl-Shift-F<br /><br /><br /><br /><br /> Open the Advanced Search form<br /><br /><br /> Ctrl-Shift-S<br /><br /><br /><br /><br /> Get help<br /><br /><br /> Ctrl-Shift-H<br /><br /><br /> These keyboard shortcuts are available anywhere within the Yahoo! Mail <br /> application, including your address book, calendar, and notepad.<br /><br /><br /> 3.2.3. Custom Keyboard Shortcuts in Firefox<br /><br /><br /> If the built-in keyboard shortcuts aren't enough for you and you use the <br /> Firefox browser, there is a way to add your own custom keyboard shortcuts. <br /> A Firefox plug-in called Greasemonkey lets users add their own bit of <br /> JavaScript to any website, which means they can add their own features, <br /> such as keyboard shortcuts.<br /><br /><br /> To get started you need to install the Greasemonkey plug-in, available at <br /> http://greasemonkey.mozdev.org/. Click the Install Greasemonkey link, and <br /> you should receive the plug-in automatically. With that, you're ready to <br /> write your code to implement the shortcuts.<br /><br /><br /> 3.2.3.1. Anatomy of a keyboard shortcut.<br /><br /><br /> This code builds on top of some JavaScript functions that already exist at <br /> Yahoo! Mail. Yahoo! Mail uses a function called addKey() to implement its <br /> own keyboard shortcuts across the site, and the following Greasemonkey <br /> script simply uses that function to add new shortcuts. This also means <br /> that the script is entirely dependent on Yahoo!, and if Yahoo! changes the <br /> code at any point in the future, this script will become useless.<br /><br /><br /> The primary pieces of the addKey() function are the first and third <br /> arguments sent. The first argument is the character code of the key that <br /> is pressed, and the third argument is the location the browser should <br /> navigate to when it encounters that code. So, if you'd like to show the <br /> address book when you click Ctrl-Shift-A, the first task is to find the <br /> character code for the letter A.<br /><br /><br /> Finding the character code for any given keyboard key isn't obvious, but <br /> you can accomplish the task with some JavaScript. Add the following code <br /> to a blank web page:<br /><br /><br /> <script><br /> document.onkeydown = showKeyCode;<br /> function showKeyCode(e) {<br /> var code;<br /> if (!e) var e = window.event;<br /> if (e.keyCode) code = e.keyCode;<br /> else if (e.which) code = e.which;<br /> var character = String.fromCharCode(code);<br /> alert('Character ' + character + ' code: ' + code);<br /> }<br /> </script><br /><br /><br /><br /><br /> Bring the webpage up in a browser, and then press any key. As you press <br /> the key, an alert window will let you know the code for the character you <br /> just pressed. As you press G, for example, the script will send the alert: <br /> Character G code: 71. You'll need the character code for any keyboard <br /> shortcut you'd like to create, and once you have them listed, you can move <br /> on to the Greasemonkey script.<br /><br /><br /> 3.2.3.2. The code.<br /><br /><br /> Save the following code to a file called yahoo_keys.user.js. It is <br /> important to include the .user.js extension because that's how Firefox <br /> knows the script is a Greasemonkey script rather than a standard <br /> JavaScript file.<br /><br /><br /><br /><br /> // ==UserScript==<br /> // @name Yahoo! Mail Keys<br /> // @namespacehttp://hacks.oreilly.com/<br /> // @descriptionUses existing Yahoo! Mail functions to add a keyboard <br /><br /><br /><br /> shortcut<br /> // @includehttp://*.mail.yahoo.com/*<br /> // ==/UserScript==<br /><br /><br /> (function() {<br /><br /><br /> // Trash | CTRL-T<br /> oKey. addKey(84,-1,"location='/ym/ShowFolder?rb=Trash'","shift+ctrl");<br /><br /><br /> // Draft | CTRL-D<br /> oKey.addKey(68,-1,"location='/ym/ShowFolder?rb=Draft'","shift+ctrl");<br /><br /><br /> // General Prefs | CTRL-G<br /> oKey.addKey(71,-1,"location='/ym/Preferences'","shift+ctrl");<br /><br /><br /><br /><br /> As you can see, each line of the script is calling the existing addKey() <br /> function. The first argument is the character code, and the third is the <br /> location the browser should visit when that key is pressed. The last line <br /> shows that the letter G (character code 71) should bring up the Yahoo! <br /> Mail Preferences page.<br /><br /><br /> By studying Yahoo! Mail URLs, you can come up with your own keyboard <br /> shortcuts. If you have a custom mail folder called Business that you'd <br /> like to access when you press Ctrl-Shift-B, you could add a line to the <br /> script like this:<br /><br /><br /> // My Business Folder | CTRL-B<br /> oKey.addKey(66,-1,"location='/ym/ShowFolder?rb=Business'","shift+ctrl");<br /><br /><br /><br /><br /> 3.2.3.3. Running the hack.<br /><br /><br /> To install your keyboard shortcuts, open yahoo_keys.user.js in Firefox. <br /> From the Tools menu, click Install User Script. Greasemonkey will ask you <br /> to confirm that you'd like to install the script for use at Yahoo! Mail. <br /> If it all looks good, click OK. From there, you can reload Yahoo! Mail to <br /> start using your custom shortcuts.<br /><br /><br /> Although Yahoo! Mail is easy to navigate even without keyboard shortcuts, <br /> you might find that you're able to accomplish routine tasks a bit more <br /> efficiently without the mouse.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 52. Manage Yahoo! Mail<br /><br /><br /><br /><br /><br /> Take control of your mail by creating folders and filters for incoming <br /> messages.<br /><br /><br /> Imagine you've just returned from vacation to find hundreds of messages <br /> waiting for you in your Inbox. Wouldn't it be nice to have an <br /> administrative assistant to sort that mail into categories and separate <br /> the good stuff from the junk? By setting up some folders and filters, you <br /> can let Yahoo! play the role of assistant, keeping your incoming mail as <br /> organized as possible.<br /><br /><br /> As in any email client, the folders in Yahoo! Mail are simply a way to <br /> organize several emails into a group. There are five built-in folders that <br /> you can't remove:<br /><br /><br /><br /><br /> Inbox<br /><br /><br /> By default, all incoming mail, except messages marked as spam, arrives in <br /> this folder.<br /><br /><br /><br /><br /> Drafts<br /><br /><br /> Any email that you have partially completed and saved for later can be <br /> found in this folder. You can also use drafts as a message template for <br /> form letters that you send frequently.<br /><br /><br /><br /><br /> Sent<br /><br /><br /> This folder holds a copy of every email you've sent. This folder is <br /> enabled by default, but you can disable it by choosing Mail Options <br /> General Preferences, unchecking the box labeled "Save your sent messages <br /> in the Sent Items folder," and clicking Save.<br /><br /><br /><br /><br /> Bulk<br /><br /><br /> Email that has been labeled as spam by Yahoo! Mail will arrive in this <br /> folder instead of your in Inbox. You can clear the email in this folder at <br /> any time by clicking the [Empty] link next to the folder listing, or have <br /> Yahoo! automatically delete anything through a setting in Mail Options.<br /><br /><br /><br /><br /> Trash<br /><br /><br /> Deleted mail goes to this folder and is subject to permanent deletion at <br /> any time. As with the Bulk folder, you can manually clear this folder at <br /> any time by clicking the [Empty] link next to this folder in the folder <br /> listing.<br /><br /><br /> You can also create your own folders and give them your own names. Figure <br /> 3-2 shows the built-in folders and two custom folders.<br /><br /><br /><br /><br /> Figure 3-2. Yahoo! Mail folders<br /><br /><br /><br /><br /><br /> 3.3.1. Sorting with Filters<br /><br /><br /> By using a combination of custom mail folders and message filters, you can <br /> let Yahoo! Mail do some sorting for you before you ever get to your Inbox. <br /> Message filters are simple rules that tell Yahoo! where to place an <br /> incoming email if it meets certain criteria that you specify.<br /><br /><br /> For example, many emails from services or mailing lists use a predictable <br /> subject line. If you're a member of the photo-sharing site Flickr, all <br /> messages from the service include the text [Flickr] in the subject line. <br /> Knowing this, you can create a custom folder for Flickr messages and set a <br /> custom filter so that the messages won't appear with your regular Inbox <br /> mail. Any folder with unread mail will be bold in your list of folders, so <br /> even though filtered mail won't show up in your Inbox, you won't miss new <br /> mail as it arrives.<br /><br /><br /> To set this up, add a new folder from your list of folders by clicking the <br /> Add link and giving it an appropriate title, such as Flickr. You should <br /> instantly see a new folder called Flickr in your list of folders. Choose <br /> Mail Options Filters to go to the Filters page. Click the Add button to <br /> bring up the Add Message Filter shown in Figure 3-3.<br /><br /><br /><br /><br /> Figure 3-3. Adding a Yahoo! Mail message filter<br /><br /><br /><br /><br /><br /> Give the filter a descriptive title; in this case, Flickr will work. <br /> Because the subject line is the predictable part, add the text [Flickr] to <br /> the Subject: field in the form. Finally, tell Yahoo! to move the mail to <br /> the folder you just created by choosing it from the drop-down list of your <br /> folders. Click Add Filter, and Yahoo! Mail will start automatically moving <br /> messages that contain [Flickr] in the subject line into the Flickr folder.<br /><br /><br /><br /><br /> Keep in mind that the more specific you can be when creating a <br /> filter, the more accurate it will be. If you set a Flickr <br /> filter to look for both [Flickr] in the subject line and <br /> flickr.com in the From: header, you'll be sure that forwarded <br /> messages from friends with the [Flickr] subject heading won't <br /> be filtered into the wrong place.<br /><br /><br /><br /><br /><br /><br /> Adding just a single folder and filter for each mailing list you receive <br /> can dramatically streamline your Inbox. As you can see, you can also add <br /> filters for specific people or specific text within a message. All of your <br /> filters are managed from the Filters page at Mail Options Filters, where <br /> you can put the filters into an order of priority. For example, maybe you <br /> want any messages from bob@example.com to go into your Bobfolder, but you <br /> want messages from Bob via a mailing list you're both on to go into the <br /> list folder instead. You could simply make the mailing list filter higher <br /> in priority than the Bob filter.<br /><br /><br /> 3.3.2. Managing Spam<br /><br /><br /> Unsolicited email is a fact of life for anyone with an email account, and <br /> no one has yet come up with a way to stop it completely. But there are <br /> some steps you can take to help control the number of junk mails you <br /> receive.<br /><br /><br /> 3.3.2.1. Use SpamGuard.<br /><br /><br /> Yahoo!'s spam-stopping service is called SpamGuard, and it's enabled by <br /> default when you create an account. As long as it's enabled, Yahoo! will <br /> scan every incoming message for signs that it is spam. If Yahoo! thinks <br /> the message is spam, the email will be routed to the built-in Bulk folder <br /> instead of your Inbox folder.<br /><br /><br /> You can choose how long messages will stay in the Bulk folder before <br /> they're deleted. Just go to Mail Options Spam Protection and choose a <br /> time, from immediate deletion to one monthgiving you the option to scan <br /> the Bulk folder periodically to make sure you're not missing good email.<br /><br /><br /> Of course if you're a glutton for punishment, you can disable SpamGuard at <br /> any time by clicking the Turn SpamGuard OFF link on that same page.<br /><br /><br /> For the spam that slips through the first line of defense, you can report <br /> individual messages as spam to Yahoo!. From your Inbox folderor any of <br /> your custom foldersclick the box next to any email that is spam. Then, <br /> with the unsolicited messages highlighted, click the Spam button. This <br /> will report the emails to Yahoo! and move the messages to your Bulk <br />folder.<br /><br /><br /> 3.3.2.2. Block specific addresses or domains.<br /><br /><br /> If a specific email sender is getting on your nerves, you can block her <br /> manually. First, open the offending message and copy the email address in <br /> the From: line at the top of the message. Browse to Mail Options Block <br /> Addresses and paste the address into the Add Block field at the top of the <br /> page. Optionally, you can block an entire domain. Simply chop off the @ <br /> symbol and everything before it in the email address and put the domain <br /> (the part after the @ symbol) into the form instead. Once set, all future <br /> mail from the address or domain will automatically be routed to the Bulk <br /> folder. You can set up to 100 blocked email addresses or domains.<br /><br /><br /> 3.3.2.3. Use temporary addresses.<br /><br /><br /> If you want to do business with a particular online shop, but you're <br /> worried that it might sell your email address to spammers, you can sign up <br /> with a temporary address. A temporary address is like an alias that you <br /> can use to sign up at online services and delete if you start receiving <br /> unwanted mail from them at any time.<br /><br /><br /> If your standard Yahoo! Mail address is example@yahoo.com, you could <br /> create a temporary address, such as temp21-shop@yahoo.com, which a third <br /> party would never be able to trace to your original address.<br /><br /><br /> Unfortunately, temporary addresses are available only as a feature of <br /> Yahoo! Mail Plus, which at the time of this writing is $20 per year.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 53. Create Yahoo! Mail Macros<br /><br /><br /><br /><br /><br /> With a combination of email drafts, direct URL bookmarks, and <br /> bookmarklets, you can send complex emails with one click.<br /><br /><br /> In the world of office software, a macro is a little bit of code that <br /> combines several steps of a process into a single click. Macros take <br /> advantage of a computer's ability to automate tasks and can significantly <br /> reduce any repetitive task that needs to be done. Taking this thinking to <br /> the world of Yahoo! Mail, you can create your own Yahoo! Mail macros to <br /> help you send messages.<br /><br /><br /> The normal process of sending a message involves going to Yahoo! Mail, <br /> clicking the Compose button, selecting a recipient, typing a subject and <br /> message, and clicking the Send button. These steps aren't very <br /> labor-intensive, but if you find yourself sending the same types of email <br /> again and again, there are a few ways you can speed things up.<br /><br /><br /> 3.4.1. Drafts<br /><br /><br /> Imagine you send a weekly email with some statistics to a group of <br /> coworkers. The introduction, explanation, and ending of the email stay the <br /> same from week to week, with only a bit of text in the middle changing <br /> each time. The simplest way to automate this type of message is with the <br /> built-in Drafts folder at Yahoo! Mail. Draft emails are like templates <br /> that can be used and reused as many times as you need.<br /><br /><br /> To create a draft, browse to the standard email form at Yahoo! Mail <br /> (http://mail.yahoo.com/) by clicking Compose Mail on the navigation menu <br /> or pressing Shift-Ctrl-P on the keyboard. Give the email a descriptive <br /> subject line, such as "weekly stats message" so you'll remember what the <br /> message is for without reading the text of the message. Create the email <br /> as if you were sending it out, but when you're finished, click the "Save <br /> as a Draft" button instead of clicking Send.<br /><br /><br /> Now, whenever you want to use the email you just composed as a template, <br /> click on the Drafts folder from your list of folders and find this message <br /> in your list. Click on the message subject to bring the email up for <br /> editing. Make any changes you need to the email, add any recipients, and <br /> click Send. The message will still be available in your Drafts folder, and <br /> you can use the message just like this at any time. If you ever want to <br /> remove a draft email from your Drafts folder, manually delete it by <br /> checking the box next to the subject and clicking the Delete button.<br /><br /><br /> 3.4.2. Yahoo! Mail Bookmarks<br /><br /><br /> Another way to automate common tasks is by creating your own Yahoo! Mail <br /> URLs. With some information about how Yahoo! Mail URLs are constructed, <br /> you can create a direct link to the Yahoo! Mail form with the fields <br /> prefilled for you. For example, if you find yourself sending out the same <br /> email over and over again, you could create a direct link to your Yahoo! <br /> Mail that includes the full message and subject, saving you some copying <br /> and pasting.<br /><br /><br /> To get started, click the Mail tab and then click the Compose button. Note <br /> the base URLeverything up to the yahoo.com. It should look something like <br /> this:<br /><br /><br /> http://us.f317.mail.yahoo.com<br /><br /><br /><br /><br /> This base URL will vary based on the localized version of Yahoo! you're <br /> using and the way Yahoo! is balancing its servers. With the base URL in <br /> hand, add the following to specify the mail form and include your Yahoo! <br /> ID:<br /><br /><br /> /ym/Compose?insert Yahoo! IDnull<br /><br /><br /><br /><br /> So, putting these pieces together will give you blank new mail form, like <br /> so:<br /><br /><br /> Insert base URL/ym/Compose?insert Yahoo! IDnull<br /><br /><br /><br /><br /> To see the form change, add a variable/value pair to the end, using an <br /> ampersand (&), variable, equals sign (=), and value. For example, <br /> &to=bob@example.com automatically adds the address bob@example.com to the <br /> form:<br /><br /><br /> Insert base URL/ym/Compose?insert Yahoo! ID null &to=bob@example.com <br /><br /><br /><br /><br /> Here are the variables you can use in the URL:<br /><br /><br /><br /><br /> to<br /><br /><br /> The email address of the recipient<br /><br /><br /><br /><br /> cc<br /><br /><br /> An email address of a copied recipient<br /><br /><br /><br /><br /> bcc<br /><br /><br /> An email address of a blind-copied recipient<br /><br /><br /><br /><br /> subject<br /><br /><br /> The subject of the email<br /><br /><br /><br /><br /> body<br /><br /><br /> The text of the message<br /><br /><br /> Using a few of these variables together can give you a fairly complex <br /> message that's ready to go without any further action required beyond <br /> clicking the Send button. Here's an example:<br /><br /><br /> http://us.f315.mail.yahoo.com/ym/Compose?insert Yahoo! IDnull&to=<br /><br /><br /><br /> bob@example.com&subject=hello&body=Hi%20Bob%2C%20this%20is%20my%20weekly%20<br /><br /><br /><br /> email%20that%20always%20has%20the%20same%20text%2E%20I%20created%20a%20<br /><br /><br /><br /> Yahoo%21%20Mail%20URL%20so%20I%20wouldn%27t%20have%20to%20re%2Dtype%20this<br /><br /><br /><br /> %20each%20time%2E<br /><br /><br /><br /><br /> Note that the message text is URL-encoded, which means some characters, <br /> such as spaces, are converted to their URL code equivalent (%20 is the URL <br /> code equivalent for a space). Look carefully between those %20 s and <br /> you'll see the text of the message. This encoding is required because some <br /> characters (such as spaces) aren't allowed in URLs. Plugging this monster <br /> URL into your address bar will bring up a page like the one shown in <br /> Figure 3-4, with the fields already filled in.<br /><br /><br /> Bookmark your newly created URL and give it a snappy name, such as "mail <br /> to bob!," and you'll have a shortcut to frequently sent mail.<br /><br /><br /> 3.4.3. Yahoo! Mail Bookmarklet<br /><br /><br /> Now that you know how to bookmark prefilled mail forms, you can take this <br /> a step further to create a Yahoo! Mail bookmarklet. A bookmarklet is a bit <br /> of JavaScript that lives inside of a browser bookmark that is executed <br /> when you click it. Since bookmarklets can interact with the page you're <br /> currently viewing in the browser, your Yahoo! Mail bookmarklet can get <br /> information like the page title, current URL, and any text you might have <br /> highlighted.<br /><br /><br /><br /><br /> Figure 3-4. A prefilled Yahoo! Mail form<br /><br /><br /><br /><br /><br /> 3.4.3.1. The code.<br /><br /><br /> This code creates a Send Link bookmarklet that sends information via <br /> Yahoo! Mail about the current web page you're viewing. As with other <br /> bookmarklets in this book, first a nicely formatted version of the code is <br /> shown, with the usable bookmarklet code to follow:<br /><br /><br /> // Dissected JavaScript bookmarklet for Send Link<br /><br /><br /> // Set d to the document object as a shortcut<br /> var d = document;<br /><br /><br /> // Set t to the currently selected text, if available<br /> var t = d.selection?d.selection.createRange().text:d.getSelection();<br /><br /><br /> // Build the body of the email that includes the current<br /> // document title, URL, and any selected text<br /> var b = d.title + '\n\n';<br /> b += d.location.href + '\n\n';<br /> b += '"' + t + '"\n\n';<br /><br /><br /> // Build the URL that will add a bookmark to Yahoo! Bookmarks<br /> var url = 'insert base URL /ym/Compose? insert Yahoo! ID null&';<br /><br /><br /> // include the tile of the current page as the subject<br /> url += 'subject ='+escape(d.title)+'&';<br /><br /><br /> // include the title of the current page<br /> url += 'body ='+escape(b)+'&';<br /><br /><br /> // also send a copy of the email to yourself<br /> url += 'cc=insert your email address';<br /><br /><br /> // open a new window to bring up the mail form<br /><br /><br /> window.open(url,<br /> '_blank',<br /> 'width=640,height=440,status=yes,resizable=yes,scrollbars=yes');<br /><br /><br /><br /><br /> As you can see, this bookmarklet builds the appropriate Yahoo! Mail URL, <br /> including a message subject and body in the URL. Both are escaped for URLs <br /> with the escape() function. The body includes the title of the current <br /> site, its URL, and any text that is selected on the page.<br /><br /><br /> And here's the code formatted appropriately for a bookmarklet:<br /><br /><br /> javascript:d=document;t=d.selection?d.selection.createRange().text:<br /><br /><br /><br /> d.getSelection();b=d.title+'\n\n'+d.location.href+'\n\n'+'"'+t+'"\n<br /><br /><br /><br /> \n';url='insert base URL /ym/Compose?insert Yahoo! ID null& subject ='+<br /><br /><br /><br /> escape(d.title)+'&body ='+escape(b)+'&cc=pb@onfocus.com';void(window<br /><br /><br /><br /> .open(url,'_blank','width=640,height=440,status=yes,resizable=&<br /><br /><br /><br /> yes,scrollbars=yes'))<br /><br /><br /><br /><br /> It's not nearly as easy to read, but it's much morSe compact. Line breaks <br /> and comments have been removed from the code, and the JavaScript has been <br /> compacted wherever possible.<br /><br /><br /> 3.4.3.2. Running the hack.<br /><br /><br /> Install the bookmarklet by creating a bookmark in your browser. <br /> Right-click the bookmark and choose Properties to edit the bookmark. In <br /> the Location field, paste the bookmarklet code and rename the bookmark <br /> Send Link!.<br /><br /><br /> Imagine you'd like to send a friend a reference to the book pictured in <br /> Figure 3-5, along with the highlighted text describing the book.<br /><br /><br /> After you click the Send Link! bookmarklet, a new window opens with title, <br /> URL, and the highlighted text prefilled at Yahoo! Mail, as shown in Figure <br /> 3-6.<br /><br /><br /> From here, it's just a matter of filling in the To: field and clicking the <br /> Send button!<br /><br /><br /> Understanding a bit more about how Yahoo! Mail works can help you <br /> streamline any repetitive email tasks or create new features similar to <br /> the Send Link! bookmarklet.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 54. Read All Your Email in One Place<br /><br /><br /><br /><br /><br /> With a little setup, you can read email from all of your accounts when <br /> you're on the go.<br /><br /><br /> Most of us collect different email addresses like keys on a key ring: we <br /> keep adding them for different locations, such as home, work, or post <br /> office boxes, and eventually we've got so many keys we can't remember <br /> which key unlocks which door. In some situations, it'd be nice to have a <br /> single master key to unlock everything, and that's exactly what Yahoo! <br /> Mail can accomplish for your email addresses.<br /><br /><br /><br /><br /> Figure 3-5. Highlighted text to be sent via email<br /><br /><br /><br /><br /><br /><br /><br /> Figure 3-6. A new window at Yahoo! Mail with prefilled text<br /><br /><br /><br /><br /><br /> If you've ever tried to check email while you're traveling, you know how <br /> frustrating it can be to check each of your email addresses with a foreign <br /> computer or in a place with limited access. While some email can wait <br /> until you're back in front of your computer, when you need to stay in <br /> touch it's important to have reliable access to your email from any <br /> computer with a web browser.<br /><br /><br /> To get started, you'll need a Yahoo!ID [Hack #3] and an activated Yahoo! <br /> Mail account. You can get an ID and activate a Yahoo! Mail account at <br /> http://mail.yahoo.com/. As soon as your account is set up, you can receive <br /> email at your Yahoo! address, and you can set up Yahoo! Mail to check your <br /> external email accounts as well.<br /><br /><br /> 3.5.1. Adding External Mail Accounts<br /><br /><br /> The only requirement for adding an outside account to Yahoo! Mail is that <br /> it must be a publicly available Post Office Protocol(POP) account. Chances <br /> are very good that all of your email accounts use the POPv3 standard.<br /><br /><br /> If you're using an Internet Message Access Protocol ( IMAP) email account, <br /> you won't be able to check that account with Yahoo! Mail. Also, Yahoo! <br /> Mail does not support encrypted SSL connections for POP accounts, so if <br /> your mail server requires an SSL connection, you won't be able to check <br /> that account with Yahoo! Mail either.<br /><br /><br /><br /><br /> Yahoo! Mail traffic is not encrypted and can be subject to <br /> eavesdropping. If your mail from external accounts is <br /> extremely sensitive, you might not want to view it via Yahoo! <br /> Mail.<br /><br /><br /><br /><br /><br /><br /> To add an account, log in to Yahoo! Mail and click Mail Options from the <br /> upper-right side of the page. Click Mail Accounts to see a summary of your <br /> accounts and then click the Add button to start adding an external <br />account.<br /><br /><br /> From here, you just need to choose a name to represent the account, such <br /> as Work or School, and then enter the mail server information that tells <br /> Yahoo! Mail how to access that external account. The mail server address <br /> will depend on the company that provides your email service, and you'll <br /> need to contact them if you don't know the mail server address. You'll <br /> also need to include the same username and password you use to check that <br /> particular email account. This gives Yahoo! Mail enough information to <br /> check the account.<br /><br /><br /><br /><br /> You'll need to choose a color to represent email from each <br /> external account. This will help you see at a glance the <br /> account each email is from as you view your Yahoo! Mail inbox.<br /><br /><br /><br /><br /><br /><br /> Once your account is set up, you'll see a list of your external mail <br /> servers on the left side of the main mail page, as shown in Figure 3-7.<br /><br /><br /><br /><br /> Figure 3-7. A list of external mail servers at Yahoo! Mail<br /><br /><br /><br /><br /><br /> You'll need to click on any external mail server you'd like to check, <br /> because Yahoo! Mail will not automatically check them. This means that if <br /> you're not ready to deal with a crisis at work while you're on a cruise <br /> ship, you can simply avoid clicking the link. After you've clicked the <br /> link, Yahoo! will contact your mail server and download any new email. The <br /> emails will appear in your inbox, and they'll be highlighted with the <br /> color that corresponds to that mail server.<br /><br /><br /> 3.5.2. Editing External Mail Accounts<br /><br /><br /> You can access your external mail accounts settings at any time by <br /> clicking Mail Accounts from the Mail Options page. To change the settings, <br /> highlight an account and click the Edit button. You can modify the <br /> settings you entered when you set up the account: mail server, name, <br /> password, and account color. And you can also set any of the following <br /> additional options:<br /><br /><br /><br /><br /> Deliver To<br /><br /><br /> You can choose an existing Yahoo! Mail folder from the menu to have all <br /> external email sent to a folder other than your Inbox. Use this option if <br /> you want to keep external mail from mingling with mail sent to your Yahoo! <br /> Mail address.<br /><br /><br /><br /><br /> Override Default POP Port<br /><br /><br /> If your mail server uses a port other than 110 for POP delivery, you can <br /> set the alternate port here.<br /><br /><br /><br /><br /> Leave Mail on POPServer<br /><br /><br /> Check this option to leave a copy of the email on your mail server. With <br /> this option checked, Yahoo! will not delete email from your mail server, <br /> so you can retrieve it again later with your standard email client. This <br /> option is enabled by default.<br /><br /><br /><br /><br /> Retrieve New Messages Only<br /><br /><br /> With this option checked, Yahoo! Mail will download only new messages from <br /> your external account, not messages that have already been retrieved. This <br /> option is enabled by default.<br /><br /><br /><br /><br /> Use Filters<br /><br /><br /> Enabling this option will apply all of your existing Yahoo! Mail filters <br /> [Hack#52] to email from external accounts. You might want to disable this <br /> if you'd rather not filter incoming external mail. This option is also <br /> enabled by default.<br /><br /><br /> Even though you might be receiving email from an external server, any <br /> replies to those messages will be from your Yahoo! Mail address. If you'd <br /> rather have your From: address be an external account, you'll need to <br /> upgrade to Yahoo! Mail Plus. At the time of this writing, a Plus account <br /> is $20 per year. You can read about all of the benefits of Yahoo! Plus at <br /> http://mailplus.yahoo.com/.<br /><br /><br /> 3.5.3. Checking Mail on Your Phone<br /><br /><br /> Another benefit of checking your external mail accounts with Yahoo! Mail <br /> is that you can read those messages via portable devices. Once the <br /> external accounts are set in Yahoo! Mail, you can use any Internet-enabled <br /> cell phone to read your mail. Point the phone's browser to <br /> http://mobile.yahoo.com/, sign in, and choose the Mail link. From there, <br /> click Check Other Mail, as shown in Figure3-8.<br /><br /><br /> You'll see a listing of all your external mail servers; click one to view <br /> messages from that account. If your current ISP doesn't offer mobile <br /> access to your email, the Yahoo! Mail external accounts feature is an easy <br /> way to enable it.<br /><br /><br /> While you might not want to read all of your mail through Yahoo! all of <br /> the time, it's comforting to know that with a bit of setup, you can <br /> receive all of your email from all of your accounts on any computer with a <br /> web browser.<br /><br /><br /><br /><br /> Figure 3-8. Checking non-Yahoo! email on a cell phone with Yahoo! Mobile<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 55. Read Yahoo! Mail in Your Preferred Email Client<br /><br /><br /><br /><br /><br /> The standard way to read Yahoo! Mail is with a web browser, but some <br /> freely available software called YPOPs! can deliver your Yahoo! Mail to <br /> your favorite email client.<br /><br /><br /> Most of us have several email accounts on several systems: one for <br /> personal email, two or three for work, and maybe even a Yahoo! Mail <br /> account on the side. Most of these accounts are read with Post Office <br /> Protocol (POP) email clients such as Outlook Express, Eudora, Thunder <br /> bird, or Mac's Mail. But Yahoo! Mail is designed to be read through a web <br /> browser. This is handy when you're away from your standard computer, but <br /> it can be a hassle when you're on your home machine. To read all of your <br /> mail and get completely caught up, you need to open both your email client <br /> and a web browser for Yahoo! Mail.<br /><br /><br /> One way to bring all of your email together is to add your standard POP <br /> accounts to Yahoo! Mail [Hack #54] so that you can read everything through <br /> a web browser.(This is another perk when you're on the road.) But if <br /> you're perfectly happy with your email client, there are also ways to <br /> route your Yahoo! Mail there.<br /><br /><br /> The most direct route is by upgrading your Yahoo! Mail account to Yahoo! <br /> Mail Plus. For an annual fee of $20 (at the time of this writing), Yahoo! <br /> Mail Plus adds various features to your account, including direct POP <br /> Access. With the upgrade, you'll be able to retrieve your Yahoo! Mail in <br /> the same way that you get mail from your other accounts.<br /><br /><br /> Another route is via YPOPs!, open source software that was put together by <br /> a handful of developers working in their spare time to solve this very <br /> problem. YPOPs! turns your machine into a minimail server and at the same <br /> time dissects the Yahoo! Mail web interface, translating web text into <br /> standard email.<br /><br /><br /> 3.6.1. Installing YPOPs!<br /><br /><br /> YPOPs! is available for just about every platform, including Windows, Mac, <br /> and Linux. To grab a copy, browse to http://yahoopops.sourceforge.net/, <br /> click the Downloads link toward the top of the page, and find the version <br /> for your operating system.<br /><br /><br /> If you're on a Windows machine, you can simply click the download file and <br /> install the program. The installation program will ask if you want YPOPs! <br /> to start when Windows starts, and you can click No here. (You can easily <br /> change this setting once the program is installed.) Once you're finished, <br /> the program will start and a new icon will appear in your system tray, as <br /> shown in Figure 3-9.<br /><br /><br /><br /><br /> Figure 3-9. The YPOPs!System tray icon<br /><br /><br /><br /><br /><br /> Right-click the new icon and choose Configure from the menu to set up some <br /> preferences. Click the Receiving Email preferences shown in Figure 3-10.<br /><br /><br /><br /><br /> Figure 3-10. The YPOPs! configuration screen<br /><br /><br /><br /><br /><br /> To play it safe, uncheck the "Empty Trash on exit" and"Empty Bulk Mail on <br /> exit" options. This will ensure you'll have a backup of every email at <br /> Yahoo!. Once you've used YPOPs! for a while, you might want to change <br /> these settings, but it's a good idea to proceed cautiously while you're <br /> learning how the program works.<br /><br /><br /><br /><br /> Even though YPOPs! has a setting to "Leave messages as unread <br /> on Yahoo! Mail server," I've found this doesn't work. No <br /> matter what the setting, YPOPs! marks emails as read and moves <br /> them to the Trash folder at Yahoo! Mail. If you suddenly have <br /> email missing that you expected to be in your inbox, they're <br /> probably in Trash!<br /><br /><br /><br /><br /><br /><br /> Once these preferences are set, click OK, and you'll be ready to move onto <br /> the final step: configuring your mail client to talk with YPOPs!.<br /><br /><br /> 3.6.2. Configuring Your Client<br /><br /><br /> The instructions for configuring your mail client vary a bit between <br /> different applications, and the YPOPs! website has step-by-step <br /> instructions for most programs. Browse to the site and choose Configuring <br /> Mail Clients in the column on the left, under Documentation. All <br /> applications follow a similar pattern, though, that goes something like <br /> this:<br /><br /><br /><br /> Open your mail client and create a new account.(This is often found <br /> under File New Account or under Tools E-Mail Accounts.) <br /><br /><br /><br /> Include your full name and your Yahoo! Mail email address. <br /><br /><br /><br /> Choose POP or POP3 as the method of delivery. <br /><br /><br /><br /> Set the incoming server to 127.0.0.1, which is computer shorthand for <br /> "this machine." <br /><br /><br /><br /> Set the outgoing server to 127.0.0.1 as well. <br /><br /><br /><br /> Set the username to your Yahoo! Mail username (your email address <br /> without the @yahoo.com on the end). <br /><br /><br /> And that's it! You should now be able to receive your email from the <br /> comfort of your favorite client. Keep in mind that you can access your <br /> Yahoo! Mail this way only when the YPOPs! program is running, so it always <br /> needs to be on in the background. If you find that you like receiving your <br /> mail this way, just click the Configure menu item again and go to the <br /> Miscellaneous preferences. You can check the option to automatically start <br /> YPOPs! when Windows starts, and you won't have to think about the program <br /> again.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 56. Manage and Share Your Schedule<br /><br /><br /><br /><br /><br /> Yahoo! Calendar can help you plan your time, manage an event, remember <br /> important events, and share your schedule with friends and family.<br /><br /><br /> When you lead a busy life, time management isn't just an important skill; <br /> it's necessary for survival. Without the ability to track important dates <br /> and times, you could miss out on key events. While you can accomplish some <br /> time management with a pencil- and-paper calendar, once your schedule is <br /> digital, you can do much more. Yahoo! Calendar Can act as your own <br /> personal assistant: reminding you of important dates and times, inviting <br /> your friends to a party, and helping your contacts plan a meeting time <br /> that's convenient for you.<br /><br /><br /> Yahoo! Calendar (http://calendar.yahoo.com/) is one piece of Yahoo! Mail, <br /> and you can view your calendar at any time by clicking on the Calendar tab <br /> at Yahoo! Mail. As you'd expect, you'll find a calendar there that you can <br /> view by the Day, Week, Month, or Year. Your Yahoo! Calendar becomes useful <br /> when you start adding personal events.<br /><br /><br /> 3.7.1. Adding Events<br /><br /><br /> There are a few ways to add events to your calendar, and an overview will <br /> help you know when to use each method of adding events.<br /><br /><br /> 3.7.1.1. Event options.<br /><br /><br /> To add a detailed event to your calendar, click the Add Event button at <br /> the top of any Yahoo! Calendar page. From there, you'll find the Add Event <br /> form that contains all of the options available for an event. Here's a <br /> look at the available fields:<br /><br /><br /><br /><br /> Title<br /><br /><br /> You can include a descriptive title for an event, but keep in mind that <br /> you're limited to 80 characters. If you like to browse your schedule by <br /> the monthly view, you might want to keep event titles fairly short, say <br /> under 10 characters.<br /><br /><br /><br /><br /> Event Type<br /><br /><br /> Choose an event type from around 30 different categories, ranging from <br /> Anniversary to Happy Hour to Wedding. The event type you assign will <br /> appear on the Event List view of your calendar, and you can sort your <br /> events by event type.<br /><br /><br /><br /><br /> Dateand Time<br /><br /><br /> You can give an event a specific date, time, and duration. For birthdays <br /> or other events that don't have a specific time, you can set the event as <br /> "all day."<br /><br /><br /><br /><br /> Location and Notes<br /><br /><br /> Use the Location field as a quick description of where the event will be. <br /> (You can include more detailed information about the location with the <br /> Address and Phone Fields.) The Notes field lets you add any extra <br /> information about an event. If set, both of these fields will appear when <br /> you hover your mouse over an event title in the Day, Week, or Month View.<br /><br /><br /><br /><br /> sharing option<br /><br /><br /> Override your default calendar- sharing option for a specific event by <br /> choosing Private, Shows as Busy, or public. Note that if your calendar is <br /> private, setting an event to public won't change your overall calendar <br /> settings.<br /><br /><br /><br /><br /> Repeating Event<br /><br /><br /> If your schedule has some regular patterns, you don't need to add each <br /> recurring event by hand. You can set a task that repeats on specific days <br /> or at specific times of the month. You can also set an end date or leave <br /> the event repeating on your calendar into the future.<br /><br /><br /><br /><br /> Invitations<br /><br /><br /> You can include a list of email addresses separated by commas, and Yahoo! <br /> will invite those people to view the event.<br /><br /><br /><br /><br /> Reminders<br /><br /><br /> Have a reminder sent to your Yahoo! Messenger account, email address, or <br /> mobile device. Reminders are great for catching birthdays and other events <br /> that can slip by.<br /><br /><br /><br /><br /> Address and Phone<br /><br /><br /> You Can specify a full address for an event, and Yahoo! will use the <br /> information to create a link to a map when you're sending invitations. You <br /> can also include a phone number, and Yahoo! will list that as well. If you <br /> aren't sending an invitation, you can use this information for you own <br /> reference when you view the event details.<br /><br /><br /> When you've filled in the options for an event, click the Save button or <br /> Save and Add Another button. One important option on this list is the <br /> ability to send invitations to an event.<br /><br /><br /> 3.7.1.2. Invitations.<br /><br /><br /> Yahoo! Calendar can also act as an invitation service if you provide a <br /> list of emails when you add an event to your calendar. Click Save to add <br /> the event, and Yahoo! will give you an extra form to fill out (as shown in <br /> Figure3-11) that will let you customize the message in the email to your <br /> guests.<br /><br /><br /> Along with your message, the email will include the event details and a <br /> link to a Yahoo! Map of the event location if you include an address. <br /> Figure 3-12 shows a Yahoo! Calendar invitation email.<br /><br /><br /><br /><br /> Figure 3-11. The Yahoo! Calendar invitation form<br /><br /><br /><br /><br /><br /><br /><br /> Figure 3-12. Yahoo! Calendar invitation email<br /><br /><br /><br /><br /><br /> In addition to sending out the invitations, Yahoo! Calendar will keep <br /> track of your guest list. As guests reply to the invitation, Yahoo! will <br /> keep track of who will be attending and will display any notes each guest <br /> has added. To see the running list of guests, as shown in Figure 3-13, <br /> click on the event in your calendar and click the View Invite list in the <br /> upper-right corner of the page.<br /><br /><br /><br /><br /> Figure 3-13. Yahoo! Calendar guest list<br /><br /><br /><br /><br /><br /> From the Invite page, you can add more guests, send an email to all of the <br /> guests, invite more people to the event, or add any of the guests to your <br /> Yahoo! Address Book.<br /><br /><br /> If you need to cancel your event, you can simply delete the event from <br /> your calendar. When you delete an event that has a list of guests <br /> associated with it, you'll have the option to notify everyone via email.<br /><br /><br /> 3.7.1.3. Quick Add Event form.<br /><br /><br /> If you're over whelmed by the number of options to fill out when you add <br /> an event, you can use the Quick Add Event form, shown in Figure 3-14, that <br /> you'll find at the bottom of any calendar view.<br /><br /><br /><br /><br /> Figure 3-14. Yahoo! Calendar Quick Add Event<br /><br /><br /><br /><br /><br /> Type the title for the event, choose the date and time, and click Add. <br /> This will instantly add an event to your calendar. You can always fill in <br /> the details later by clicking the event title.<br /><br /><br /> 3.7.1.4. Tasks.<br /><br /><br /> Similar to events, tasks are listed on the left side of the calendar, and <br /> you can use them to build a to-do list. Tasks won't show up on the <br /> calendar as events; they're completely independent. You can give each task <br /> a due date and a priority, and you can view them all at any time by <br /> clicking the Tasks tab.<br /><br /><br /> 3.7.1.5. Time Guides.<br /><br /><br /> You can include national holidays, financial events, and sports team <br /> schedules on your calendar by adjusting your Time Guides settings. Click <br /> Options at the top of any Yahoo! Calendar page, and then click Time Guides <br /> under the Events heading. You can choose which types of events you'd like <br /> to include or exclude, including your Yahoo! Friends and Groups calendars. <br /> Click the Add/Edit link next to any category to make changes. For example, <br /> you can click Add/Edit next to Holidays and change the holidays that show <br /> up on your calendar. Choose a category from the drop-down menu to see <br /> holidays for other continents or religious holidays.<br /><br /><br /> 3.7.2. Sharing Your Calendar<br /><br /><br /> Once your calendar is filled with events, you might want to share that <br /> calendar with specific Yahoo! users or the world. To start sharing your <br /> calendar, you'll need to set your sharing options by going to any Yahoo! <br /> Calendar page and choosing Options Management Sharing. From the Sharing <br /> page, you can set your calendar to be as public or private as you'd like, <br /> as shown in Figure 3-15.<br /><br /><br /><br /><br /> Figure 3-15. Yahoo! Calendar sharing options<br /><br /><br /><br /><br /><br /> The term Friends on the sharing options page refers to a specific list of <br /> Yahoo! IDs you have approved to view your calendar. Click the Edit List <br /> link to add or remove Yahoo! IDs from your list. As you add each Yahoo! <br /> ID, you can also specify whether the member with that ID can modify your <br /> calendar. The term Anyone literally refers to anyone in the world, whether <br /> they have a Yahoo! ID or not. If you choose to make your calendar <br /> available to anyone, be sure that the calendar doesn't have personally <br /> identifiable information that you wouldn't want some stranger to have. For <br /> example, you might not want to let the world know when you'll be away from <br /> your house on vacation.<br /><br /><br /> You can also choose a default privacy setting for event details. The "Show <br /> as Busy" option will let others know you're busy at a specific time, but <br /> it won't let them know where you'll be. The Public setting will let others <br /> know the details of your schedule. When you're finished, be sure to click <br /> Save at the bottom of the page to modify the sharing options of your <br /> calendar.<br /><br /><br /> Once you've made your calendar available to others, you can easily share <br /> it by sending the calendar's URL. You'll find the URL at the bottom of the <br /> sharing options page, and it's in this predictable format:<br /><br /><br /> http://calendar.yahoo.com/insert Yahoo! ID<br /><br /><br /><br /><br /> Sharing schedules can help a group plan meetings; it can also keep <br /> everyone in your family from missing important dates and times.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 57. Add Contacts to Your Yahoo! Address Book<br /><br /><br /><br /><br /><br /> Add contacts to your Yahoo! Mail Address Book from incoming email or <br /> existing desktop address books.<br /><br /><br /> Frequent travelers know the frustration of having data trapped inside <br /> desktop applications. Imagine you find yourself in a foreign hotel <br /> roomneeding to contact your hostonly to realize that the email address you <br /> need is in your Outlook address book at your office. One solution to this <br /> problem is to use a web-based address book, such as the one included with <br /> Yahoo! Mail, to keep your contact information available from any computer <br /> connected to the Internet. Another reason to keep addresses at Yahoo! is <br /> that you'll find it speeds up composing email at Yahoo! Mail. By choosing <br /> addresses from your address book, instead of typing in email addresses <br /> manually, you'll save some keystrokes and save your brain the work of <br /> remembering complex addresses.<br /><br /><br /> One of the biggest hurdles to using a web-based address book, though, is <br /> the time involved with building your list of contacts. Luckily, Yahoo! <br /> offers a number of ways to enter contact information into your address <br /> book from manually entering each address to importing addresses in <br />batches.<br /><br /><br /> 3.8.1. Entering Contacts Manually<br /><br /><br /> The fastest way to enter a single contact into the Yahoo! Address Book is <br /> from inside an email. As you're reading an email at Yahoo! Mail, look for <br /> the "Add to Address Book" link in the From: line of the mail headers at <br /> the top of the email; it will look like Figure 3-16.<br /><br /><br /><br /><br /> Figure 3-16. Add to Address Book link in Yahoo! Mail<br /><br /><br /><br /><br /><br /> Click the link, and you'll see the "Add to Address Book" form with several <br /> of the fields prefilled, including first and last name and email address. <br /> You can optionally add a phone number and nickname for the contact and <br /> click the "Add to Address Book" button to save the contact into your <br /> address book.<br /><br /><br /> Though this is simple, it won't work if you're starting a new Yahoo! Mail <br /> account or if you haven't received email at your Yahoo! address from the <br /> contacts you want to add. To enter a few contacts by hand, browse to <br /> http://address.yahoo.com/ and look for the Quick Add Contact box at the <br /> top or bottom of the page. If you're going for speed, the minimum <br /> information you need to fill in is a first or last name and an email <br /> address; then click the Add button.<br /><br /><br /> To spend a bit more time and build a more complete address book, you can <br /> click the Add Contact button found at http://address.yahoo.com/ and you'll <br /> have the option to associate much more information with the contact:<br /><br /><br /><br /><br /> Name<br /><br /><br /> Including first, last, middle, and a nickname. Note that if you use <br /> nicknames to address a message when composing email, each nickname should <br /> be unique.<br /><br /><br /><br /><br /> Email<br /><br /><br /> The contact's primary email address and up to two alternates.<br /><br /><br /><br /><br /> Messenger ID<br /><br /><br /> The contact's Yahoo! ID for receiving instant messages.<br /><br /><br /><br /><br /> Phone Numbers<br /><br /><br /> Up to seven different numbers, including home, work, mobile, fax, and <br /> pager.<br /><br /><br /><br /><br /> Home Information<br /><br /><br /> The complete address; also space for a URL.<br /><br /><br /><br /><br /> Work Information<br /><br /><br /> The company name, job title, complete address, and URL.<br /><br /><br /><br /><br /> Important Dates<br /><br /><br /> Birthday and anniversary information.<br /><br /><br /><br /><br /> Notes<br /><br /><br /> Any information that doesn't fit in the other categories.<br /><br /><br /> In addition to this information, you can assign your contact to a category <br /> that you can set up through the Options link at the top of the page. <br /> Categories are handy for grouping contacts by association, such as Friends <br /> and Work. If these fields don't meet your needs, you can also add up to <br /> four custom fields (also available through the Options link) for extended <br /> information.<br /><br /><br /><br /><br /> If you give a contact a nickname in the address book, you can <br /> simply address any future Yahoo! Mail to that nickname.<br /><br /><br /><br /><br /><br /><br /> As you can see, there is a lot of information you can fill out here, and <br /> adding more than a handful of contacts this way can become a chore.<br /><br /><br /> 3.8.2. Importing Contacts<br /><br /><br /> If you've already entered your contact information in a desktop program <br /> such as Outlook, there's no need to go through the hassle again. There are <br /> several quicker ways to build up your Yahoo! Address Book.<br /><br /><br /> 3.8.2.1. Using QuickBuilder.<br /><br /><br /> If you've been using Yahoo! Mail for any length of time, you probably have <br /> a library of emails sitting on Yahoo!'s servers. Clicking through each <br /> email, finding the "Add to Address Book" link, and adding each contact <br /> could take hours, so Yahoo! built a tool called QuickBuilder. QuickBuilder <br /> searches through your existing Yahoo! Mail, looking for contacts to add to <br /> your address book.<br /><br /><br /> To get started, browse to your address book and click the QuickBuilder <br /> button in the navigation bar. From here, you can select which folders <br /> Quick-Builder should look through to find addresses. You can also limit <br /> the number of emails QuickBuilder finds by specifying that it should <br /> include only addresses that appear more than one to four times in your <br /> folders, or addresses from emails received within a specific timeframe. <br /> Click Continue to display the list of email addresses QuickBuilder finds. <br /> Check the box next to each found address if you'd like to add it to your <br /> address book.<br /><br /><br /> You can also add a nickname for each contact before you add it to your <br /> address book. Alternately, check the box at the top left of the results to <br /> select every email address found. Click Continue to display a list of the <br /> addresses that have been added.<br /><br /><br /> 3.8.2.2. Importing from applications.<br /><br /><br /> Luckily, all email application designers understand that people migrate <br /> between different computers, locations, and email programs on a fairly <br /> regular basis, and if you've spent years compiling an address book in <br /> another program such as Outlook, you can take advantage of your email <br /> application's export features to use your existing data.<br /><br /><br /> The first task in moving your contacts is to find a format that Yahoo! <br /> Mail can understand and import. This is called exporting your address <br /> book, and the exporting process generates a file on your computer that you <br /> can send to Yahoo!. First, take a look at the four address book formats <br /> that Yahoo! understands:<br /><br /><br /><br /><br /> Microsoft Outlook CSV<br /><br /><br /> This is a simple text file with comma-separated values (CSV) in a format <br /> used by Microsoft Outlook and Outlook Express.<br /><br /><br /><br /><br /> Palm Desktop ABA<br /><br /><br /> Choose the Address Book Archive (ABA) format if you're importing from a <br /> Palm handheld PDA.<br /><br /><br /><br /><br /> Netscape LDIF<br /><br /><br /> Use the Lightweight Directory Interchange Format (LDIF) option if you're <br /> exporting from the Mozilla Thunderbird email client or older Netscape <br /> email clients.<br /><br /><br /><br /><br /> Yahoo! CSV<br /><br /><br /> If you're moving from one Yahoo! ID to another or consolidating multiple <br /> Yahoo! Mail accounts into one, you can choose to export into the Yahoo! <br /> CSV format and then import the file.<br /><br /><br /> The process for exporting an address book will vary by application, and <br /> you can find a list of step-by-step instructions for many email clients in <br /> Yahoo! Help at http://help.yahoo.com/help/us/ab/impexp/index.html. <br /> Generally, you start the export process from the program menu at File <br /> Import and Export. From there, you want to choose to export to a file in <br /> one of the formats that Yahoo! understands. You'll also want to give it a <br /> memorable name, such as address_book.csv, and save it in a memorable <br /> location like your desktop.<br /><br /><br /> Now that you have your address book file in a format Yahoo! can <br /> understand, browse to your Yahoo! Address Book and click the Import/Export <br /> link in the upper-right corner of the page (see Figure 3-17).<br /><br /><br /> As you can see, on this page you choose the format of your file, click <br /> Browse… to find the file on your computer, and then click the Import Now <br /> button. The next page you'll see is your address book filled with the <br /> contact information from your export file.<br /><br /><br /><br /><br /> Figure 3-17. Yahoo! Mail Import and Export<br /><br /><br /><br /><br /><br /> 3.8.2.3. Staying in sync.<br /><br /><br /> The process of importing contacts from another program works well for <br /> moving a large number of contacts between your desktop and Yahoo! Mail. <br /> But if you'd like a more incremental approach, Yahoo! offers a program for <br /> Windows users called Intellisync for Yahoo!. Intellisync is a program you <br /> can download and install that will keep information from certain desktop <br /> applications in sync with Yahoo! Mail. Syncing address books is only one <br /> service provided by Intellisync, which can move tedious tasks such as <br /> importing and exporting contacts to the background. For example, if you <br /> add Uncle Joe as a contact in Outlook on your home computer, Intellisync <br /> will recognize the addition and add Uncle Joe to your Yahoo! Address Book.<br /><br /><br /> To install Intellisync, click the Sync link in the upper-right corner of <br /> your Yahoo! Address Book and make sure your other address book application <br /> is listed on the following page. At the time of this writing, Intellisync <br /> supports syncing the address book from specific versions of seven <br /> applications or platforms: ACT!, Lotus Organizer, MS Outlook, Outlook <br /> Express, Palm handhelds, and Pocket PCs. If your current address book <br /> isn't supported, Intellisync won't work for you. If you find your version <br /> of your application listed, click Install Now to download the program.<br /><br /><br /> Once you've installed Intellisync, you'll need to tell it which address <br /> book program you use. Start the program and click the Setup button. Click <br /> Application Settings to bring up the configuration window shown in Figure <br /> 3-18.<br /><br /><br /><br /><br /> Figure 3-18. Intellisync configuration<br /><br /><br /><br /><br /><br /> Select Address Book from the list and then click Choose… to choose your <br /> address book application. Find your address book program on the list, <br /> highlight it, and leave "synchronize" checked. From there, save your <br /> changes by clicking OK, and you're set up to keep your address books <br /> synchronized.<br /><br /><br /> Once you've set up Intellisync, you can run it periodically to sync your <br /> address book entries in both places. If Intellisync spots any differences <br /> between the two address books, you'll be asked to confirm any edits before <br /> they're made, as shown in Figure 3-19.<br /><br /><br /><br /><br /> Figure 3-19. Intellisync address book confirmation<br /><br /><br /><br /><br /><br /> To see the details of any changes, click the Details… button to see <br /> exactly which contacts are being sent back and forth.<br /><br /><br /> The process of entering contacts into your Yahoo! address book can be a <br /> tedious one, but by taking some time to work with the tools Yahoo! has <br /> made available, you can build up your address book in no time and have all <br /> of your contacts at your fingertips from any location.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 58. Map Yahoo! Address Book Contacts<br /><br /><br /><br /><br /><br /> Plot the locations of your friends and colleagues on a map of the world <br /> with your Yahoo! Address Book and the worldkit mapping application.<br /><br /><br /> The Yahoo! Address Book lets you store more than just names and email <br /> addresses. You can store complete contact information for everyone, <br /> including street address, city, state, and country. If you have more than <br /> a dozen or so contacts stored, you might not realize how geographically <br /> dispersed everyone is. This hack plots the locations of all of your Yahoo! <br /> Address Book contacts on a map, so you can visualize where your friends, <br /> family, and coworkers live.<br /><br /><br /> Plotting each contact's location is possible thanks to Yahoo!'s Address <br /> Book export feature, which provides all of your address book data in <br /> commaseparated value (CSV) format. From there, a freely available web <br /> service called Geocoder (http://geocoder.us/) translates each address into <br /> its longitude and latitude. And finally, worldkit <br /> (http://brainoff.com/worldkit) plots each point on a map.<br /><br /><br /> 3.9.1. Preparing Your Address Book<br /><br /><br /> Right now, your address book might be in sloppy condition (mine was), <br /> including misspelled addresses, missing states and countries, and <br /> abbreviated cities. Geocoding requires some degree of accuracy to find <br /> good matches, so before getting started, tidy your address book up. It's <br /> not necessary to produce a pristine address book, but you need at least a <br /> city and country, and a state abbreviation for U.S. locations. Street <br /> addresses for U.S. contacts can be used too. You'll likely need to iterate <br /> this cleanup a couple of times, with feedback from the geocoding script. <br /> Export your contacts by loading http://address.yahoo.com/, selecting <br /> Import/Export, and selecting Export Now! for the Yahoo! CSV format.<br /><br /><br /> 3.9.2. The Code<br /><br /><br /> yadr2geo.pl is a Perl script that takes the name of your downloaded <br /> address book and outputs a geocoded RSS file to use with worldkit. <br /> Geocoded RSS refers to any flavor of RSS extended to include item-level <br /> latitude and longitude. More details on the format can be found at <br /> http://brainoff.com/worldkit/doc/rss.php#basic.<br /><br /><br /> This script requires commonly installed modules: URI::Escape for <br /> formatting web service requests, LWP::Simple for making those requests, <br /> and XML::Simple for parsing the responses.<br /><br /><br /><br /><br /> This script does not use a module to parse CSV, because <br /> modules such as Text::CSV assume that a newline indicates a <br /> new record, while in Yahoo! CSV (and most flavors of this <br /> unofficial spec) it's legal to include a newline within an <br /> entry if that entry is quoted. CSV is discussed in more detail <br /> at http://www.creativyst.com/Doc/Articles/CSV/CSV01.htm.<br /><br /><br /><br /><br /><br /><br /> Yahoo! CSV is simple: all entries are guaranteed to be quoted, the first <br /> line gives field names, and there's no extraneous whitespace. So it's <br /> straight-forward to program a script to parse Yahoo! CSV character by <br /> character. The subroutine geTRecord() takes an open filehandle as an <br /> argument and returns an array containing the next CSV record.<br /><br /><br /> Save the following code to a file called yadr2geo.pl:<br /><br /><br /> #!/usr/bin/perl -w<br /><br /><br /> use strict;<br /> use XML::Simple qw(XMLin);<br /> use LWP::Simple qw(get);<br /> use URI::Escape qw(uri_escape);<br /><br /><br /> # Map your personal country naming conventions<br /> # to country codes listed at <br />http://brainoff.com/geocoder/countryselect.php<br /> # and change the default country if you wish<br /> my %countrycode = ('USA' => 'US');<br /> my $defaultcountry = 'US';<br /><br /><br /> print <<RSSHEADER;<br /> <?xml version="1.0"?><br /> <rss version="2.0"><br /> <channel><br /> <title>Yahoo! Address Book
http://address.yahoo.com/
My geocoded Yahoo! Address Book
RSSHEADER


my (%hash, @vals, $arg, $loc, $lat, $lon, $success, $country);


# First line of Yahoo! CVS is keys
my @keys = @{ getrecord(*STDIN) };


while (! eof(STDIN)) {
@vals = @{ getrecord(*STDIN) };
@hash{ @keys } = @vals;


$success = 0;
undef($loc);
$country = $countrycode{ $hash{'Home Country'} } || $defaultcountry;


# Check for sufficient information to geocode


if (length($hash{'Home City'}) == 0
|| ($country eq "US" && length($hash{'Home State'}) == 0)) {
print STDERR "Couldn't geocode: \""
. join ("\",\"", @vals) . "\"\n";
next;
}


# Try geocoding US street address
if ($country eq 'US'
&& length($hash{'Home Address'}) > 0) {
$arg = $hash{'Home Address'} . "," . $hash{'Home City'}
. "," . $hash{'Home State'};


eval {
# Be patient, geocoder.us free service is rate limited
$loc = XMLin(
get("http://geocoder.us/service/rest/?address="
. uri_escape($arg) )
);
};


if (!$@ && defined($loc->{"geo:Point"}->{"geo:long"}) &&
defined($loc->{"geo:Point"}->{"geo:lat"})) {
$success = 1;
}
}


# Try geocoding world city
if ($country ne 'US' || ! $success) {
if ($country ne "US") {
$arg = $hash{'Home City'} . "," . $country;
} else {
$arg = $hash{'Home City'} . "," . $hash{'Home State'}
. "," . $country;
}
eval {
$loc = XMLin(
get("http://brainoff.com/geocoder/rest?city="
. uri_escape($arg))
);
};


if (!$@ && defined($loc->{"geo:Point"}->{"geo:long"}) &&
defined($loc->{"geo:Point"}->{"geo:lat"})) {
$success = 1;
}
}


if ($success) {
print <
$hash{'First'} $hash{'Last'}
$loc->{"geo:Point"}->{"geo:lat"}
$loc->{"geo:Point"}->{"geo:long"}



ITEM
} else {
print STDERR "Couldn't geocode: \""
. join ("\",\"", @vals) . "\"\n";
}
}


print "\n";


#
# "getrecord" returns the next record as an array from an open
# filehandle. It is a simple state machine, that expects a file
# formatted in 'Yahoo! CVS'
#
sub getrecord {
my $fh = shift;
my $c = "";
my $st = 0;
my @record;
my $entry = "";
while (defined($c)) {
$c = getc($fh);
if ($st == 0) {
if ($c eq "\n" || ! $c) {
return \@record;
} elsif ($c eq "\"") {
$st = 1;
} else {
die "error: parsing state:$st char:$c\n";
}
} elsif ($st == 1) {
if ($c eq "\"") {
$st = 2;
} else {
$entry .= $c;
}
} elsif ($st == 2) {
if ($c eq "\"") {
$entry .= "\"";
$st = 1;
} elsif ($c eq ",") {
push @record, $entry;
$entry = "";
$st = 0;
} elsif ($c eq "\n") {
push @record, $entry;
return \@record;
} else {
die "error: parsing state:$st char:$c\n";
}
}
}
die "error: premature end of file\n";
}




The main body of the script builds a hash from the current record,
attempts to geocode the address, and outputs an RSS item if it's
successful. For U.S. locations with full street address, the REST service
from http://geocoder.us/ is employed. It expects an address, city name,
and state abbreviation, and it returns a small bit of XML containing a
latitude/longitude pair if it's successful. The free service is rate
limited, so you'll notice pauses during requests. For non-U.S.
locationsand for unsuccessful Geocoder requestsa request is made to the
REST interface of the Geocoder at http://brainoff.com/geocoder, which
expects a city, state abbreviation for U.S. cities, and country code.


The country codes are particular to the GNS
(http://earth-info.nga.mil/gns/html) database that backs this service. To
look up the codes, go to http://brainoff.com/geocoder/countryselect.php
and select a country; a JavaScript alert will give you the code. You will
need to map the country names used in your address book to these codes, by
adding entries to %countrycode in the script.


If you use a non-English language on Yahoo!, you might have different
field names from the ones expected. The script uses Home Address, Home
City, Home State, and Home Country. You might need to examine your CSV
export and replace these field names in the code. Similarly, if you wanted
to map work addresses, you'd replace Home with Work in each of these field
names. Another modification to try is adding a or
field to each item, set, for example, to the Personal Website field.


3.9.3. Running the Hack


With the script and the Yahoo! CSV export file (yahoo.csv) in place, call
the script like this:


perl yadr2geo.pl < yahoo.csv > rss.xml




The file rss.xml will contain each of the entries from your Yahoo! Address
Book, along with its geocoded location.


3.9.4. Plotting the Addresses


The final step is to download worldkit from http://brainoff.com/worldkit
and install it on your server or locally. Loading the included index.html
in your browser displays the default map. Replace the included rss.xml
with the output of yadr2geo.pl and reload the map. You'll see the
locations of your friends spread over the globe, as in the geographically
dispersed map in Figure 3-20.




Figure 3-20. Yahoo! Address Book entries plotted on a worldkit map





There are many possible customizations described in the worldkit
documentation, from changing the map from global to city scale, to
changing the annotation colors according to the category of each contact.


Mikel Maron
















Hack 59. Discuss, Share, and Collaborate with Others





Use Yahoo! Groups to set up a space to share information via email and on
the Web.


The Web is redefining how groups of people can work together to achieve a
common goal. At one time, forming collaborative relationships meant
meeting in the same physical location. By collaborating online, people
across the globe can come together to work on a project, exchange
information, or simply chat. A family that's distributed across the
country can share photos and stories, or a local club can plan meeting
times.


Yahoo! Groups is a space that facilitates these kinds of relationships,
and at its most basic, Yahoo! Groups provides an easy way to create a
mailing list. A mailing list is simply a way to send an email to a number
of specified email addresses. Some mailing lists are one-way, meaning the
list owner sends email to everyone on the list but members don't
communicate between each other; these are called announcement or
distribution lists. A two-way list is called a discussion list and allows
any of its members to send an email to the list; everyone on the list will
receive the message. A Yahoo! Group can have either type of mailing list,
but Yahoo! Groups are most often thought of as a place for discussion.


3.10.1. Group Features


In addition to its mailing list, every Yahoo! Group has its own group
site. Here are the features you'll find at a Yahoo! Groups site:




Messages


Every message sent to the group via email is archived at the group site,
where members can search through past messages or post new messages to the
group.




Chat


A Java™ application that runs in the browser provides real-time chatting
for members that are at the group site at the same time.




File, Photo, and Link Sharing


Members can upload files and photos to share with others. And there's a
special section of the group site for sharing links to other sites.




Shared Databases


The group can work together on a database of information. You can even
create your own structure for the data. Prebuilt options include a shared
phone book, CD library, recipes, and contact list.




Group Polls


You can take the pulse of the group by creating a multiple-choice poll
question and letting members vote on the choices.




Shared Calendar


Everyone can keep each other informed of important events by adding event
descriptions to the group calendar.


Each Yahoo! Group site offers a number of features that aren't available
via email.


3.10.2. Joining a Group


Though you might be tempted to rush into creating your own group, you
might find that a group already exists for your favorite topic.


There are millions of public Yahoo! Groups, and you can search for groups
or browse by topic at http://groups.yahoo.com/. Say you're interested in
robotics and want to see what people are discussing. You could browse
through the categories to Science Engineering Mechanical Robotics and find
a listing of around 500 potential groups, as shown in Figure 3-21.


Each Yahoo! Group listing shows the title and description, the number of
members, and whether the message archive is open to the public. If the
archives are public, you can read through past discussions to see if
you're interested in the group. Otherwise, you might have to join the
group and try it out.


When you spot a group you might like to join, click the group title and
you'll visit the group site, like the one shown in Figure 3-22.




Figure 3-21. A listing of Yahoo! Groups







Figure 3-22. An individual Yahoo! Groups site





Across the top of the group page, you'll notice that it lists the group
activity within the past seven days. This includes messages posted to the
group and any files, photos, or links shared. This is a good way to get a
sense of how active a particular group is. You'll also be able to read the
entire group description and read through recent messages if the archives
are public. Click Join This Group! to become a member. At this point,
you'll need to log in with your Yahoo! ID if you're not logged in already.


After you decide to join a group, you'll need to decide how you'd like to
receive messages. You can choose your preferred email address for the
group and how you'd like to receive messages at that address:




Individual Emails


With this setting, you'll receive every individual email sent to the
group. This is a good option if you want to be in the thick of daily
conversation.




Daily Digest


A digest is a group of all the messages to the group for a day, joined
together into one email. This is a good option if you'd like to keep close
tabs on the group but don't want to participate heavily in the
conversation.




Special Notices


With this option, you'll receive only messages that the group moderators
mark as important. Use this option if you primarily read messages at the
group site but want an occasional update.




No Email


You can read a group exclusively at the group site and avoid any extra
messages in your inbox.


You can also choose whether you prefer plain-text or HTML-formatted email.


Once you're a member, you'll be able to post messages to the group, access
the archives, and use the extended features of the group site. Keep in
mind that some groups require approval from a moderator before allowing
you to become a member, and some groups require that all messages sent to
the group are approved by a moderator before they're sent on to the entire
group.


3.10.3. Creating a Group


To start your own group, browse to http://groups.yahoo.com/ and click the
"Start a group now" link. You'll need to log in if you haven't done so
already. You can create a group in three steps:




Choose a Category


You need to place your group within a Yahoo! Groups category, even if the
group is going to be private. If your group is for a family, you could
place it in Family & Home Families Individual Families.




Describe the Group


Enter a group name, email address prefix, and description. This
description is the group's public face to the world and will appear in the
Yahoo! Groups directory if the group is public. The email address prefix
will also determine the group site URL, so choose something short and
memorable.




Confirm Your Address


Choose your preferred email address to receive messages at the group, and
prove you're not a robot by filling out a captcha form, as you may have
done when you created a Yahoo! ID [Hack #3].


With the group created, there's nothing more you need to do. You can start
inviting people to join your group and start the discussion. You can view
your group site by visiting its URL, which is in this format:


http://groups.yahoo.com/group/insert email prefix




Even though your group is ready to go with the default options, click the
Management link on the left side of the home page to see all of your
administrative options. The links under the Group Settings headings will
let you configure every aspect of your group, from public archives to the
look and feel of the group site.















Hack 60. Archive Yahoo! Groups Messages with yahoo2mbox





Looking to keep a local archive of your favorite mailing list? With
yahoo2mbox, you can import the final results into your favorite mailer.


With the popularity of Yahoo! Groups (http://groups.yahoo.com/) comes a
problem. Sometimes, you want to save the archives of a Yahoo! Group,
access the archives outside the Yahoo! Groups site, or move your list
somewhere else and take your existing archive with you.


3.11.1. The Code


Vadim Zeitlin had these same concerns, which is why he wrote yahoo2mbox
(http://www.tt-solutions.com/en/products/yahoo2mbox). This hack retrieves
all the messages from a mailing list archive at Yahoo! Groups and saves
them to a local file in mbox format. Plenty of options make this handy to
have when you're trying to transfer information from Yahoo! Groups. You'll
need Perl and several additional modules to run this code, including
Getopt::Long, HTML::Entities, HTML::HeadParser, HTML::TokeParser, and
LWP::UserAgent.


3.11.2. Running the Hack


Running the code looks like this:


perl yahoo2mbox.pl [options] [-o mbox] groupname




The options for running the program are as follows:


--helpgive the usage message showing the program options
--versionshow the program version and exit
--verbosegive verbose informational messages (default)
--quietbe silent, only error messages are given
--resumeresume an interrupted download
-o mboxsave the message to mbox instead of file named groupname
--start=nstart retrieving messages at index n instead of 1
--end=nstop retrieving messages at index n instead of the last one
--last=nget the last specified number of messages from the list
--noresumedon't resume, **overwrites** the existing output file if any
--user=namelogin to eGroups using this username (default: guest login)
--pass=passthe password to use for login (default: none)
--cookies=xxxfile to use to store cookies (default: none,
'netscape' uses netscape cookies file).
--proxy=urluse the given proxy, if 'no' don't use proxy at all (even not
the environment variable http_proxy which is used by default),
may use http://username:password\@full.host.name/
--country=xxuse the given country code in order to access localized yahoo
--x-yahooadd X-Yahoo-Message-Num header to identify Yahoo! messages
--delay=nsleep for the specified number of seconds between requests




So, this command downloads messages from Weird Al Club, starting at
message 3258:


% perl yahoo2mbox.pl --start=3258 weirdalclub2
Logging in anonymously… ok.
Getting number of messages in group weirdalclub2…
Retrieving messages 3258..3287: .............................. done!
Saved 30 message(s) in weirdalclub2.




Here, the messages are saved to a file called weirdalclub2. Renaming the
file weirdalclub2.mbx means that I can immediately open the messages in
Eudora, as shown in Figure 3-23. Of course, you can also open the
resulting files in any mail program that can import (or natively read) the
mbox format.




Figure 3-23. A Yahoo! Groups archive in Eudora





3.11.3. Hacking the Hack


Because this is someone else's program, there's not too much hacking to be
done. On the other hand, you might find that you don't want to end this
process with the mbox file; you might want to convert to other formats for
use in other projects or archives. In that case, check out these other
programs to take that mbox format a little further:




hypermail (http://sourceforge.net/projects/hypermail/)


Converts mbox format to cross-referenced HTML documents.




mb2md (http://www.gerg.ca/hacks/mb2md/)


Converts mbox format to Maildir. Requires Python and Procmail.




mb2md.pl (http://batleth.sapienti-sat.org/projects/mb2md/)


Converts mbox format to Maildir. Uses Perl.


Kevin Hemenway and Tara Calishain
















Hack 61. Explore Your Social Networks





Use Yahoo! 360 to stay in touch with friends, family, and coworkers while
viewing their social connections.


You've probably heard the famous theory that says everyone on earth can be
connected to anyone else through six degrees of separation. For example,
if you really wanted to get in touch with Bill Gates through friends, you
could go to someone you know, they could go to someone they know, and
you'd eventually reach Bill through no more than six contacts. These
relationships make up your social network, and Yahoo! 360 is an attempt to
map and expose those connections.


In addition, Yahoo! 360 is a place to keep your friends, family, and
coworkers up-to-date with what's happening in your life, as well as a way
for you to see what they're up to. It's also a way to meet your friends'
friends, and perhaps meet some people you wouldn't have otherwise met.
Some of the features you'll find at Yahoo! 360 include:




Your personal profile


Assemble an autobiography and list cities you've lived in, places you've
worked, and schools where you've studied. You can also put together lists
of favorite movies, music, and television shows.




Weblog


You can keep a personal public journal that will keep your friends
up-to-date with your recent thoughts and activities.




Friends list


Assemble a list of your contacts that are on Yahoo! 360 and stay in touch
with them.




Yahoo! Network


You can integrate Yahoo! Network data into your personal profile,
including Yahoo! Photos you've uploaded, Yahoo! Groups you belong to, and
your Yahoo! Local reviews.


Whether you arrive at Yahoo! 360 by invitation or by signing up at
http://360.yahoo.com/, you should take a few steps before you start
connecting with others to get the most out of your Yahoo! 360 space.


3.12.1. Create a Profile


Your Yahoo! 360 profile is your public face to others. As people run into
your weblog or see your comments on other weblogs, they'll be able to view
your profile to learn more about you. When you log into Yahoo! 360, you'll
find your profile page full of empty yellow boxes, as shown in Figure
3-24.


This page is a blank canvas that you can begin to fill in with details
about yourself. A good place to start is the Edit Basic Info link on the
left side of the page. From there, you can enter your name and a nickname,
and decide how you want your identity displayed to others.


You can include other bits of information, such as your current location,
age, birthday, and primary email address. Most settings allow you to
specify a privacy setting, as shown in Figure 3-25, and you'll find
similar settings throughout Yahoo! 360.


The default value for information entered into Yahoo! 360 is "just me"
(private), and you might want to leave this value alone until you're
finished with your Yahoo! 360 space and ready to connect with others. You
can always click the Edit Basic Info link later to change your basic info
privacy settings.


Once your basic info is set, click Save to return to your profile page.
Because photos are used extensively throughout Yahoo! 360, a good next
step is uploading a personal photo. The personal photo space is fairly
large, so if you'd like to include an image without any distortion, create
a personal photo that's 190 pixels wide by 245 pixels high. The photo will
need to be in the standard JPEG format. You can upload up to four
different photos, and people reading your profile will be able to click on
thumbnails to see them at the 190 x 245 size.




Figure 3-24. A blank Yahoo! 360 profile







Figure 3-25. Choosing a privacy setting for a piece of information





With your personal photos in place, click the Create Profile link at the
bottom of your profile page. This is where your autobiography begins, and
you can tell people as little or as much about yourself as you'd like.
Yahoo! 360 provides a space for describing yourself, forms for listing
places you've lived, worked, or gone to school, a space to list your home
page, a way to list languages you speak, and a spot for your favorite
quote. Click Save when you're finished, and you should start to see your
profile page taking shape.


Click Share Lists to add lists of things you're interested in. These lists
help you connect with other Yahoo! 360 members by interest. You can list
general interests, favorite books, movies, music, and television shows.


Finally, click Edit Contact Settings on the left side of your profile page
and decide how you'd like to receive messages from other Yahoo! 360
members. You can allow anyone to contact you, just people you've
designated as friends, or friends of friends within your network. You can
also adjust the settings for Yahoo! 360 friend invitations and Yahoo!
Messenger settings. Now that you have a home base set and you've decided
how you'd like to be contacted, you can start connecting with others.


3.12.2. Start Blogging


A blog (short for weblog), is a public journal that can be a way to share
opinions, a place to describe recent activities, or simply a space to
chronicle interesting things you find on the Web. To set up your blog, go
to your profile page and click the "Start a Blog" link and give your new
weblog a title and description. You can also choose to activate a Simple
URL for your blog. The default URLs for Yahoo! 360 weblogs aren't easy to
pass around. Here's what a standard Yahoo! 360 blog URL looks like:


http://blog.360.yahoo.com/blog-W.nEFiYoc6l2SMTF4MyXa0E-




But you can enable a Simple URL that contains your Yahoo! ID and is much
more manageable, something like this:


http://blog.360.yahoo.com/yhoohacks




Yahoo! 360 uses the first, more complex URL as the default, so that your
Yahoo! ID isn't immediately available to others. If you don't mind sharing
your Yahoo! ID with others, though, you can have a much simpler URL to
share with friends and family.


Next, choose who can see your blog: anyone (public), friends in your
network, or just you (completely private). If you choose the public
option, you can also publish a site feed. With a site feed, others can
subscribe to your weblog through My Yahoo! or other RSS newsreaders.
Finally, choose who can comment on your posts and click the Begin Blog
button.


You'll find yourself at your weblog, without any posts. Click the Compose
New Entry link on the left to write your first message to the world. Just
as with email, each post has a title and a body (entry content). In most
browsers you can format the text of your post with the controls just above
the Entry Content area. Figure 3-26 shows some of the formatting options
available, including bold, italics, links, smileys, and lists.




Figure 3-26. Posting to a Yahoo! 360 blog





If you're familiar with HTML, you can skip the formatting buttons and
write the HTML yourself by selecting the View HTML Source option. Be aware
that your HTML options are limited; you'll need to brush up on what's
allowed at Yahoo! 360 by clicking the "Learn more" link under the Entry
Content area.


If you include a photo with your post, the photo will appear at the top of
the post when it's published. The photo will be scaled to 284 pixels wide
once it's uploaded to Yahoo! 360. The photo will appear directly under the
title and above the main body of the post once the post is published.


Once you're happy with your entry, click Post This Entry to make the post
available on your blog. Who can read your words will depend on your
privacy settings. An occasional blog entry is an unobtrusive way to keep
friends, coworkers, and family up to speed on what's happening in your
life. Plus, your friends and family can add their own comments to your
posts, which keeps a public dialogue going.


Another option available on your Yahoo! 360 blog is a tool for building a
blogroll. A blogroll is simply a list of links to other blogs and sites
you enjoy. To add sites to your blogroll, click the My Blog link at the
top of any Yahoo! 360 page and click the Edit Blogroll link. From there,
you can add sites by typing in a site's name and URL. If you're moving
from another weblog service and already have a blogroll, you might want to
automate this process [Hack #62].


3.12.3. Connect with Friends


The strength of Yahoo! 360 lies in your connections with other members. As
you add people to your friends list, you'll see their recent activity and
they'll see yours. Figure 3-27 shows a Yahoo! 360 home page listing the
latest information from friends.




Figure 3-27. A Yahoo! 360 home page with friends' current activity





There are a few different ways to build your own friends list. You can
click the Home link at the top of any Yahoo! 360 page and then click the
"Invite a Friend" link from the left side of the home page. From there,
you can send an invitation email and personal message to someone you know.
If she accepts your invitation, joins Yahoo! 360, builds a profile, and
starts posting to a weblog, she'll be listed as a contact, and you'll see
her latest activity on your home page.


Another way to spot friends is by browsing your existing friends' lists.
If we're all connected by six degrees, you shouldn't have to surf other
friends' lists long before you find people you know. You can also click
the Search link at the top of any Yahoo! 360 page to search for people you
know, or you can enter specific criteria such as location, age, or schools
attended to find people you don't know (yet).


You can also click My Page at the top of any Yahoo! 360 page to get to
your profile. If you've assembled lists of books, music, and movies you
enjoy, you can click those titles to see other Yahoo! 360 members who
share that interest. For example, if you've listed Kraftwerk as a musical
favorite, simply click the Kraftwerk link to see others who like the
German electronic group. If you see someone you'd like to add to your
friends list, click the Invite link next to his name. If he accepts your
invitation, he'll be added to your friends list, and you'll see his latest
activity on your home page.


In addition to weblog posts and comments, you can communicate privately
with other Yahoo! 360 members through your Mailbox. As you'd expect, you
can reach your Yahoo! 360 Mailbox by clicking the Mailbox link at the top
of any Yahoo! 360 page. Whenever you see someone you'd like to talk with,
click the Send Message link next to her name. The messages are similar to
email, but your email address isn't exposed in the process. This way, you
can contact people with as little or as much anonymity as you'd like.
















Hack 62. Import an Existing Blogroll to Yahoo! 360





Moving your blog to Yahoo! 360 and already have a blogroll? Automate
adding blogroll links with OPML and Perl.


A prominent feature of most weblogs is a list of links to other weblogs
running down the side of the page. This list is called a blogroll, and
they're so popular that a service called Blogrolling
(http://www.blogrolling.com/) is there to help people maintain large lists
of links and easily include them on their own weblog.


Yahoo! 360 [Hack #61] also features a blogroll and a blogroll manager
(http://blog.360.yahoo.com/blog/blogroll.html). To add a link to your
blogroll, add the site name and URL into the form. If you'd like to add
more links, click the Add Another button at the top of the page to reveal
more fields. Adding a handful of links this way is fine, but if you
already have a list of 10 or more sites you'd like to include, this can
get tedious quickly. Luckily, there's a standard way of exchanging links
that can make the job faster.


As more and more services offer the ability to create blogrolls or lists
of links, the way to exchange these lists is an XML format called Outline
Processor Markup Language ( OPML). OPML can be used to syndicate lists of
just about anything. Sites such as Blogrolling and the newsreader
Bloglines (http://www.bloglines.com/) use OPML to import and export long
lists of web sites. For example, at Bloglines, you can subscribe to your
favorite web sites to read their posts. Using Bloglines on a regular
basis, you can accumulate a list of hundreds of sites. If you'd like to
use this same list of accumulated sites with another service, you can use
Bloglines's export function to get an OPML list of the site names and
URLs.


Each individual entry in an OPML file exported from Bloglines looks like
this:


type="rss" xmlUrl="http://radar.oreilly.com/index.rdf"/>




As you can see, the OPML file contains the title and URL of the site, and
the location of the site's RSS feed. Having your list of favorite sites in
this structured way can help you automate adding the sites to your Yahoo!
360 blogroll. Figure 3-28 shows a Yahoo! 360 blogroll that's been imported
with the code in this hack.


Instead of typing in each entry by hand into the Yahoo! 360 form, you can
let Perl do the heavy lifting for you.


3.13.1. The Code


This code relies on a nonstandard component called WWW::Mechanize to
handle the automation. Among other things, WWW::Mechanize can log in to
web sites and fill out formsperfect for adding a batch of entries to the
Yahoo! 360 blogroll editor. You'll also need to install the
Yahoo!-specific component WWW::Yahoo::Login, which works with
WWW::Mechanize to log in to your Yahoo! account.


Once the components are installed, save the following code to a file
called import_blogroll_360.pl and be sure to add your Yahoo! ID and
password to the script. Also, take a look at your current blogroll form
(available at http://blog.360.yahoo.com/blog/blogroll.html) and count the
number of rows you see. If you're starting with a blank blogroll, the
number should be 3. Add this number to the code at the line my $i= n. This
will tell the script where to begin adding links and will ensure that any
current links you have at your Yahoo! 360 blogroll won't be overwritten.




Figure 3-28. A Yahoo! 360 imported blogroll





#!/usr/bin/perl
# import_blogroll_360.pl
# Imports links from an OPML file into Yahoo! 360 Bookmarks
# Usage: import_blogroll_360.pl


use strict;
use WWW::Yahoo::Login qw( login logout );
use WWW::Mechanize;


# Open the incoming file
open(OPML, "@ARGV") || die "usage: import_blogroll_360.pl ";
my @opml = reverse ;


my $mech = WWW::Mechanize->new();


# Log into Yahoo! 360
my $resp = login(
mechq=>$mech,
uri=>'http://blog.360.yahoo.com/blog/blogroll.html',
user=>'insert Yahoo! ID' ,
pass=>'insert Yahoo! Password' ,
);


# Set the beginning field value
my $i = n;
my $form = $mech->current_form();


# If login succeeded, loop through the OPML


if ($resp) {
# Parse the OPML
foreach my $link (@opml) {
# Depending on the flavor of OPML you're parsing
# you may need to edit this regex
while ($link =~ /]. */gi) {
$i++;
my $title = $1;
my $url = $2;
# Set title field
my (%titleattr);
$titleattr{name} = "title_$i";
$titleattr{value} = $title;
$form->push_input("text", \%titleattr);
$mech->field("title_$i", $title);
# Set URL field
my (%urlattr);
$urlattr{name} = "url_$i";
$urlattr{value} = $url;
$form->push_input("text", \%urlattr);
$mech->field("url_$i", $url);
print "$title - $url\n";
}
}
$mech->field("amt",$i);


# Submit the form
$mech->click("save");
} else {
warn $WWW::Yahoo::Login::ERROR;
}




This script is set to parse the output from Bloglines, and other services
might have slightly different flavors of OPML that will require some
changes. Even though OPML is emerging as a standard, the format is
flexible and different services implement it in different ways. For
example, Bloglines uses a title attribute to indicate the title of a site,
while some others use a text attribute. If the flavor of OPML that you're
working with is different, change the line that contains the format of the
tag (bold in the code).


3.13.2. Running the Hack


To run the code, call it from the command line and pass in the name of
your OPML file. So if your Bloglines export file is named
bloglines_export.xml, you'd invoke the script like this:


perl import_blogroll_360.pl bloglines_export.xml




Once executed, the script logs in to Yahoo! 360 with your Yahoo! ID and
password and analyzes the blogroll form. From there, it loops through the
OPML file, adding the proper fields and values to the Yahoo! 360 form.
Once it's through the file, $mech->click("save") does the work of clicking
the Save button, and you'll have your old blogroll in a new location!


















Hack 63. Add an API to Your Yahoo! 360 Blog





Start using third-party services with your Yahoo! 360 blog by adding your
own API.


Yahoo! 360 is a site designed to help you keep in touch with friends,
family, and coworkers. In addition to sharing reviews, photos, and lists
of your favorite music and movies, Yahoo! 360 lets you post messages in a
blog. Of course, Yahoo! isn't the only place you can keep a blog. Services
such as Blogger (http://www.blogger.com/) and TypePad
(http://www.typepad.com/) will also host a blog for you. But if your
friends are all chatting away on Yahoo! 360, you might want to keep a
journal there, where you and your friends can all connect.


At the time of this writing, Yahoo! 360 is in beta testing, and its
developers are working on the features they intend to offer for a wider
release. Unfortunately, this means the blog portion of Yahoo! 360 isn't as
robust as some of the other weblog services, and Yahoo! 360 doesn't yet
offer a way to post to your weblog from third-party services. For example,
if I keep a weblog on Blogger, I can post photos to that weblog from
Flickr (http://www.flickr.com/), a photo-sharing application recently
acquired by Yahoo!. That's because Blogger offers an application
programming interface (API) that lets other services access data
programmatically.


Even though Yahoo! 360 doesn't offer an API, with a bit of scripting you
can mimic a weblog API and start posting through third-party tools.


3.14.1. What You Need


To implement this hack, you'll need access to a publicly available web
server that can run Perl scripts, and several external modules. Here's a
look at the modules you need, what they provide, and where you can find
them:




XMLRPC::Transport::HTTP


This module handles all of the formatting of XML-RPC requests and
responses required for the metaWeblog API interface. The module is part of
a larger package called SOAP::Lite. To read the documentation, go to
http://search.cpan.org/~byrne/SOAP-Lite-0.60a/lib/XMLRPC/Transport/HTTP.pm.




LWP::Simple


This module allows you to download the contents of pages from the Web. It
is available at
http://search.cpan.org/~gaas/libwww-perl-5.803/lib/LWP/Simple.pm.




WWW::Mechanize


Also known as Mech, this module can automate interactions with a website.
This hack uses Mech to log in to Yahoo! and post items to a Yahoo! 360
weblog. To download the module and read its documentation, go to
http://search.cpan.org/~petdance/WWW-Mechanize-1.12/lib/WWW/Mechanize.pm.




WWW::Yahoo::Login


This module is an extension of Mech that handles logging in to Yahoo!
sites. Find it ar
http://search.cpan.org/~struan/WWW-Yahoo-Login-0.10/lib/WWW/Yahoo/Login.pm.




Image::Size


This module can find the dimensions in pixels of any image. It's used in
this hack to find the dimension of images posted from Flickr. You can read
more at http://search.cpan.org/~rjray/Image-Size-2.992/Size.pm.


If you're missing any of these modules, you can install each of them with
CPAN, like this:


perl MCPAN e shell
cpan> install insert package name




With the modules in place, you're ready to move on to the script.


3.14.2. The Code


This code doesn't fully implement all of the functions you'll find in the
metaWeblog API. Instead, it implements two methods: getUsersBlogs and
newPost. These two methods are the bare minimum needed to interface with
other systems and add new weblog posts.


As you'd expect, getUsersBlogs returns a list of weblogs that a particular
user can post to at a weblog service. Because Yahoo! 360 users are limited
to one blog per Yahoo! ID, this function simply logs in to Yahoo! and
fetches the name of the user's Yahoo! 360 blog. The newPost function also
logs in to Yahoo!, changes the incoming text of a post if necessary, and
adds the text as a new post to the Yahoo! 360 weblog.


Save the following code to a file called Y360_api.pl:


#!/usr/bin/perl
# Y360_api.pl
# Implements a minimalist metaWeblog API for Yahoo! 360 blogs.
# You can read more about the metaWeblog API here:
# http://www.xmlrpc.com/ metaWeblogApi
#
# Usage: send metaWeblog API requests for methods:
#
#getUsersBlogs
#Returns the name and URL of a Yahoo! 360


#blog for the given user.
#newPost
#Adds a post with the incoming text to
#a Yahoo! 360 blog for the given user.


use strict;
use XMLRPC::Transport::HTTP;


XMLRPC::Transport::HTTP::CGI
-> dispatch_to('metaWeblog')
-> handle
;


package metaWeblog;
use WWW::Yahoo::Login qw( login logout );
use WWW::Mechanize;
use Image::Size 'html_imgsize';
use LWP::Simple;


my $mech = WWW::Mechanize->new(autocheck => 1);


sub getUsersBlogs {
my($app, $msg, $user, $pass) = @_;


# Set some defaults
my $blog_url = "http://blog.360.yahoo.com/blog/";
my $blog_name = "My Yahoo! 360 Blog";


# Log into Yahoo! 360
my $mech = WWW::Mechanize->new();
my $login = login(
mech => $mech,
uri => 'http://blog.360.yahoo.com/blog/',
user => $user,
pass => $pass,
);


# Get weblog URL and title
if ($login) {
my $html = $mech->response()->content( );
if ($html =~ m!

(.*?)

!mgis) {
$blog_name = $1;
}
if ($html =~ m!
  • View Blog
  • !mgis) {
    $blog_url = $1;
    }
    }


    # Send the response
    my @res;
    push @res, { url => SOAP::Data->type(string => $blog_url),
    blogid => SOAP::Data->type(string => "1"),
    blogName => SOAP::Data->type(string=> $blog_name) };
    \@res;
    }


    sub newPost {
    shift if UNIVERSAL::isa($_[0] => __PACKAGE__);
    my($blog_id, $user, $pass, $item, $publish) = @_;


    # Log into Yahoo! 360
    my $mech = WWW::Mechanize->new();
    my $login = login(
    mech => $mech,
    uri => 'http://blog.360.yahoo.com/blog/compose.html',
    user => $user,
    pass => $pass,
    );


    # Add width/height to image tags (for Flickr posts)
    if ($item->{description} =~ m!(.*?.*)!mgis) {
    my $file = get($2);
    my $size = html_imgsize(\$file);
    $item->{description} = "$1 $size $4";
    }


    # Write post description to a file
    open(FILE, ">> post.txt") or die("Couldn't open post.txt\n");
    print FILE $item->{description} . "\n\n";


    # Remove initial div tag from del.icio.us posts
    $item->{description} =~ s!



    !$1!gis;


    # Strip line breaks
    $item->{description} =~ s!\n!!gis;


    # If login succeeded, add post and send a successful
    # response with the generic 1000 as the post ID
    if ($login && $item->{title}) {
    my $form = $mech->form_name("blog_compose");
    $mech->field("title", $item->{title});
    $mech->field("contents", $item->{description});
    $mech->click("post");
    SOAP::Data->type(string => "1000");
    } else {
    return error $WWW::Yahoo::Login::ERROR;
    }
    }




    This script is built specifically to work with the API-related services at
    Flickr [Hack #67] and del.icio.usa bookmark manager available at
    http://del.icio.us/. The newPost subroutine reformats incoming text based
    on the text that these services provide. For example, Flickr doesn't
    provide height and width attributes for image tags in the HTML it
    produces, and Yahoo! 360 requires those attributes in weblog posts. So
    this script uses the Image::Size module to add those attributes to the
    text.


    3.14.3. Running the Hack


    To run the hack, upload Y360_api.pl to a publicly available web server and
    note the URL. It should look something like this:


    http://example.com/Y360_api.pl




    Be aware that this URL is sometimes referred to as an API Endpoint, so
    don't let the jargon throw you off. Whenever a service asks for a URL,
    this is the one you should use.


    The final step is to test out your new API at a third-party service. Since
    the script was built specifically for Flickr, that's a good place to
    start. Follow the steps to set up a weblog at Flickr [Hack #98] and choose
    MetaWeblogAPI Enabled Blog as your weblog type, enter your script's URL as
    the Endpoint, and include your Yahoo! ID and password.


    Flickr will contact your script behind the scenes with a getUsersBlogs
    request, and your script will send back the title and URL of your Yahoo!
    360 weblog. Once your weblog is set up in Flickr, you can click the Blog
    This button above any photo and choose your Yahoo! 360 weblog (see Figure
    3-29).




    Figure 3-29. The Blog This button at Flickr





    From there you can compose your post at Flickr and see the finished
    product as a post on your Yahoo! 360 blog like that shown in Figure 3-30.




    Figure 3-30. A Flickr image posted to a Yahoo! 360 blog





    The code takes a bit of time to set up, but once you wire this shortcut
    for yourself, you may find that you use both Yahoo! 360 and Flickr more
    often.
















    Hack 64. Create a Yahoo! Avatar





    Make a custom caricature of yourself and watch it smile or cry along with
    you as you chat through Yahoo! Instant Messenger.


    Having an instant messaging conversation on the computer is a bit like
    having a conversation with a blindfold on. You can "hear" what the other
    person is saying clearly by reading what he types, but other cues, such as
    facial expressions, are completely absent. Without seeing and hearing the
    person you're chatting with, it's hard to pick up on emotional overtones
    such as humor, sadness, or sarcasm. This is exactly why we've developed
    text shortcuts to convey emotions over the Internetfor example, using an
    emoticon to indicate smiling, or using an abbreviation such as LOL to
    indicate that you're laughing out loud.


    Yahoo! has taken this idea of conveying emotion a step beyond such text
    shortcuts by creating cartoon-like characters called avatars to stand in
    for some of these emotional cues during Yahoo! Instant Messenger
    conversations. With a little work, you can create your own avatar that's
    unique to your personality and let it stand in for you as you chat with
    people online.


    3.15.1. Your Digital Double


    To create the Internet representation of you, browse to the Yahoo! Avatars
    site (http://avatars.yahoo.com/). (You'll need to be at a Windows computer
    and have the Flash plug-in installed for your browser.) Once you're there,
    log in and choose the gender of your avatar (male or female); all other
    options will flow from this choice. You can then go on a virtual shopping
    spree to change the look of your avatar in a number of ways:




    Appearance


    Match your skin color, face shape, eye color, or hairstyle.




    Apparel


    Dress your avatar up in different tops and bottoms.




    Extras


    Give your avatar bags, jewelry, scarves, sports items, pets, hats, or
    holiday-specific items.




    Backgrounds


    Put your avatar in a specific location, such as a school or vacation spot.




    Branded


    Give your avatar the latest brand-name apparel.


    As you go from section to section changing your avatar, you can keep track
    of your changes on the Previewing Changes panel on the left side of the
    page, as shown in Figure 3-31.


    As you click different apparel items or extras, you'll find them listed
    under the "What I'm trying on" box below the preview panel. When you find
    a combination you like, click Save to move the list of items to the "What
    I'm wearing" box. If you ever find that you've accidentally added a ski
    outfit and your avatar is in a beach scene, click the Clear button to
    revert to your last saved avatar.


    There are quite a few customizations to click through, and if you ever
    spot something you'd like to come back to, you can add an outfit or scene
    to your Favorites section to keep them just a click away. (You can see
    your favorites at any time by clicking the My Favorites link from the
    Yahoo! Avatars toolbar.) You can also save entire avatars to your
    Favorites list, giving you quick access to fairly complex combinations
    quickly. But keep in mind that if you ever decide to change genders,
    you'll lose all of your previously saved avatars!




    Figure 3-31. Dressing up a Yahoo! avatar





    3.15.2. Getting Moody


    Just as your avatar can reflect your physical appearance to some degree,
    your avatar can also reflect your mood. At the top of the preview panel in
    Figure 3-31, you can see five face icons that represent different moods.
    Clicking on each face changes your avatar to display a different emotion,
    such as happy, excited, sad, or angry. Figure 3-32 shows the whole range
    of available emotions.




    Figure 3-32. A Yahoo! avatar showing its emotions





    There's also a special mood that changes based on the selections you've
    made for your avatar's facial appearance. If you don't set a specific mood
    for your avatar when you're in the designing process, you avatar will
    still emote while you're chatting.


    Once your avatar is set, start Yahoo! Instant Messenger and log in.
    Double-click an ID in your friends list to bring up a chat window, and
    click the small head icon next to the Send button. This will make your
    avatar visible to you while you're chatting with others. If your friend on
    the other end is also using the Windows version of Yahoo! Instant
    Messenger, she'll see your avatar as well.


    As you're chatting, you might notice that your avatar changes expression
    from time to time. For example, if you type LOL in a conversation, your
    avatar will have a big smile for a moment and return to its normal
    expression. There is a whole series of words and emoticons that will
    change the expression of your avatar. Here are a few of the most common
    expressions that avatars can display, along with different strings you can
    type to trigger each one:




    Neutral


    happy, nice, or :) (the standard smiling emoticon)




    Excited


    hehe, haha, rotf (for "rolling on the floor"), lol, or excited




    Sad


    boo, hoo, or :( (the frowning face emoticon)




    Angry


    hmmph, grr, or angry


    To trigger the special mood for a specific avatar, you can type (*). A
    complete list of avatar-altering words is available at
    http://help.yahoo.com/help/us/avatar/avatar-14.html.


    You can also change the mood of your avatar by clicking the avatar within
    Yahoo! Instant Messenger and choosing Set Avatar Mood To. This option
    allows you change between the five basic moods shown in Figure 3-32.


    While using an avatar can never replace face-to-face communication, Yahoo!
    Instant Messenger avatars communicate some extra information about
    identity and emotions as you're communicating in an environment that's
    largely limited to text.















    Hack 65. Add a Content Tab to Yahoo! Messenger





    With a bit of Registry hacking, you can add a custom content tab to Yahoo!
    Instant Messenger.


    Yahoo! Messenger (http://messenger.yahoo.com/) is more than just a way to
    have conversations with your friends. It's is also a way to keep up with
    your favorite Yahoo! content. Across the bottom of the Yahoo! Messenger
    window, you'll find a series of content tabs. Each tab gives you instant
    access to some information you'd normally find on the Yahoo! website, such
    as weather, stock quotes, news headlines, or your Yahoo! calendar. Figure
    3-33 shows a series of content tabs in Yahoo! Messenger, with the Yahoo!
    Buzz tab selected.




    Figure 3-33. The Yahoo! Buzz content tab in Yahoo! Messenger





    The Yahoo! Buzz tab gives you a quick summary of what you'll find at the
    Yahoo! Buzz site (http://buzz.yahoo.com/), tracking trends in Yahoo!
    searching. You can customize which tabs appear in Yahoo! Messenger by
    choosing Messenger Preferences from the top menu and selecting the Content
    Tabs category from the left pane. From there, you can choose from around a
    dozen different tabs to show or hide from your Yahoo! Messenger interface.




    This hack describes the latest version of Yahoo! Messenger for
    Windows. At the time of this writing, the Mac version of
    Yahoo! Messenger has four content tabs, and there's no way to
    add custom tabs to the interface






    The choices you'll find in your Yahoo! Messenger settings are static, and
    you can't add or remove tabs you find from within the preferences
    interface. But this hack shows how to add your own content tab to Yahoo!
    Messenger by tweaking some settings behind the scenes.




    Thanks to Marcus Foster at Yahoo! for sharing this method of
    adding a tab!






    3.16.1. Inside Your Registry


    All of the content tabs within Yahoo! Messenger are defined within the
    Windows Registry, a database that stores system settings. You can take a
    look at the settings for each of the tabs by viewing the settings in the
    Registry Editor. Start the Registry Editor by clicking Start Run and
    typing regedit.




    Be very careful when editing your Registry settings. If you
    change the wrong setting, you could do irreparable harm to
    your system. Just be aware that the Registry settings are
    vital to your system, and if you're not comfortable tooling
    around in sensitive areas, you might want to skip this hack!






    With the registry editor open, browse to the following key:
    HKEY_CURRENT_USER\Software\Yahoo\Pager\View\. Beneath the View key, you'll
    find a series of registry keys with the prefix YMSGR_. These are the
    available content tabs, and you can highlight each to see the system
    settings. Figure 3-34 shows the Registry key for the Yahoo! Buzz tab, with
    its system settings in the right pane.




    Figure 3-34. Yahoo! Messenger content tab settings in the Registry





    The important settings to note are Display Name, Display Bmp, and content
    url. The first two set the tab name and icon. And because each tab display
    is simply a web page, the content url value is where you'll find the page
    for a particular tab. In fact, you can visit any tab page in Internet
    Explorer including the Yahoo! Buzz content tab at
    http://tools.search.yahoo.com/ym/buzz.


    The key to adding your own tab to Yahoo! Messenger is creating a new
    Registry key with content url set to a URL of your choosing. And the
    easiest way to create a new key with all of the proper settings is to copy
    an existing key. Inside the Registry Editor, highlight the YMSGR_buzz key,
    right-click, and click Export. Save the key as YMSGR_buzz.reg, and you'll
    be set to create your own tab.


    So, what type of web page makes a good content tab? The best content tab
    page will be compact, with its contents viewable in a small space. Most
    pages probably won't fit very well into a content tab, and you'll have to
    design a page specifically for use within Yahoo! Messenger. If you've
    already added a Yahoo! Bookmarks sidebar [Hack #30] to your browser,
    you'll know there's already a page available to display your Yahoo!
    Bookmarks in a small space. There isn't a Bookmarks content tab currently
    available in Yahoo! Messenger, but the following Registry changes will add
    one.


    3.16.2. The Code


    Copy the YMSGR_buzz.reg file and to a new file and name the new file
    YMSGR_bookmarks.reg. Open the file in Notepad and make the following
    changes to the Registry settings within. Note that the changes are in
    bold.


    Windows Registry Editor Version 5.00


    [HKEY_CURRENT_USER\Software\Yahoo\Pager\View\YMSGR_bookmarks]
    "Display Name"="Bookmarks"
    "Display Bmp"="YView\\ybang.bmp"
    "default"=dword:00000001
    "insert"=dword:00000001
    "enable browsing"=dword:00000001
    "Stat Letter"="B"
    "click count"=dword:00000000
    "persistent"=dword:00000001
    "content url"="http://my.yahoo.com/tearoff/sites.html"
    "MinHeight"=dword:0000001e
    "PreferHeight"=dword:000000d1
    "Resizable"=dword:00000001
    "Refreshable"=dword:00000000




    The key name has been changed to YMSGR_bookmarks and the display name is
    set to Bookmarks. There isn't a custom icon for the Bookmarks tab (because
    it doesn't exist yet), so the icon has been changed to ybang.bmp, a
    generic Yahoo! icon included when you install Yahoo! Messenger.




    If you want to go the extra mile for your custom content tab,
    you could create your own icon to display it. Use the icons in
    the YView directory of your Yahoo! Messenger installation as a
    guide.






    Finally, the content url setting points to your Yahoo! Bookmarks
    minimalist display URL.


    3.16.3. Running the Hack


    Click Save in Notepad to save your modified Registry file, and then
    doubleclick YMSGR_bookmarks.reg. Confirm that you'd like to add the
    settings to the Registry, and you should receive a message that the
    contents were added. Restart Yahoo! Messenger and keep in mind that even
    if you close the Yahoo! Messenger window it can still be running in the
    taskbar. You'll need to completely restart the program and then bring up
    the Content Tabs category in your Preferences. You should see the new
    option to add a Bookmarks tab, as shown in Figure 3-35.




    Figure 3-35. Adding a new content tab in Yahoo! Messenger





    Highlight the Bookmarks tab, click the Show button, and click OK to close
    your Preferences. You should see the new tab along the bottom of Yahoo!
    Messenger. Click the Bookmarks tab with the generic Yahoo! icon, and you
    should see your Yahoo! Bookmarks appear in the content pane, as shown in
    Figure 3-36.




    Figure 3-36. The Bookmarks content tab in Yahoo! Messenger





    Of course, a custom content tab doesn't have to be Yahoo! content as in
    this example. Because content tabs are simply standard URLs, you could
    easily create your own pages and have instant access to your own custom
    information while you're chatting with friends.


    3.16.4. Hacking the Hack


    Sites specifically designed for mobile devices like cell phones and PDAs
    work extremely well as Yahoo! Messenger content tabs. If you can track
    down a URL for a mobile site, you can create your own tab. For example,
    Yahoo!'s photo-sharing service Flickr [Hack #67] has a mobile site
    available at http://flickr.com/mob. Change the key and display names in
    the Registry file, and set content url to the Flickr mobile URL. Once you
    run the file, restart Yahoo! Messenger and add the new tab. You'll end up
    with the content shown in Figure 3-37.


    With the Flickr tab in place, you can easily keep tabs on the photos your
    friends are posting without opening up a web browser.




    Figure 3-37. Flickr mobile in a Yahoo! Messenger content tab





    Yahoo! also has a mobile site (http://wap.oa.yahoo.com/); you could easily
    set up a Yahoo! tab and have access to all your personalized Yahoo!
    content in a single Yahoo! Messenger tab.
















    Hack 66. Send Instant Messages Beyond Yahoo!





    In a world where your friends are using different instant messaging
    systems, speak with all of them using Trillian.


    If Yahoo! Instant Messenger is your favorite way to chat with friends,
    ideally everyone you know would also use Yahoo! Instant Messenger. But the
    world isn't a perfect place, and there are many competing instant
    messaging applications, including AOL Instant Messenger ( AIM), ICQ,
    Microsoft's MSN Messenger, and Apple's iChat. Unfortunately, a friend
    using AIM can't talk with another friend using ICQ. And neither of these
    friends would be able to chat with you on Yahoo! Instant Messenger.
    Instead of trying to convince everyone you know to switch to your favorite
    applicationor installing four different programsyou could switch to a
    universal instant messaging program: Trillian.


    Cerulean Studios, the company behind Trillian, recognized this
    communication breakdown between instant messengers and decided to make a
    program that could speak with all of them. Trillian lets you chat with
    anyone on Yahoo!, AIM, ICQ, or MSN. It works by connecting directly with
    servers for each service and mimicking the messages sent from the standard
    messaging program. The basic version is free, and Trillian Pro offers a
    few more features for $25.


    Trillian runs only on Windows 98 or above, so Linux and Mac users are out
    of luck. You'll also need an account with each service you'd like to
    communicate with. But to get started, you'll just need your Yahoo! ID and
    password.




    Mac OS X users might want to try the freely available Fire
    application, which is similar to Trillian. You can download
    Fire from http://fire.sourceforge.net/.






    3.17.1. Installation and Setup


    From the Cerulean Studios homepage (http://www.ceruleanstudios.com/),
    click Downloads and then click the Download button on the next page.
    Because Cerulean Studios distributes the program through its partner CNet,
    the download link takes you to Download.com (http://www.download.com/).
    From there, choose Download Now to get the program. Double-click the
    installation file to install Trillian.


    When you launch Trillian for the first time, you'll see the Trillian First
    Time Wizard, which will step you through setting up the program. On the
    Choose Features page, make sure that Yahoo! Messenger is selected and
    click Next. When you see the "Connect to Yahoo! Messenger" page as shown
    in Figure 3-38, enter your Yahoo! username and password.




    Figure 3-38. Trillian Yahoo! Messenger setup





    If you already have a contact list in Yahoo! Instant Messenger, Trillian
    will get the list of contacts when it connects with Yahoo!. ( Trillian
    will do the same for accounts on other systems as well.) If the connection
    works as planned, you should see a list of your contacts across instant
    messaging systems, as shown in Figure 3-39.




    Figure 3-39. Instant messaging contacts from different platforms





    The contacts are color-coded, with Yahoo! users in red. To add a Yahoo!
    contact at any time, choose Trillian from the top menu and then choose Add
    Contact or Group. From there, select Yahoo as the medium, and fill out the
    form you see in Figure 3-40 with your friend's Yahoo! ID and a brief
    message.




    Figure 3-40. Adding a Yahoo! contact in Trillian





    You can also set up multiple Yahoo! IDs with Trillian and connect to any
    or all of them at once. This is handy if you have a separate account for
    personal and work contacts, or multiple Yahoo! IDs for different
    situations. To add a new Yahoo! ID at any time, choose Trillian from the
    top menu, then Connections Manage My Connections. Click "Add a New
    Connection" at the bottom of the page and then choose Yahoo. Then add a
    Yahoo! username and password, and Trillian will connect with that ID as
    well.


    3.17.2. What You'll Miss


    The Windows versions of both Yahoo! Instant Messenger and Trillian work
    well for sending text messages back and forth, but there are some
    differences between the programs you should be aware of. Unlike Yahoo!
    Instant Messenger, Trillian doesn't offer instant access to other Yahoo!
    features, such as LaunchCast, Games, Stock Quotes, Weather, and your
    Yahoo! Calendar and Address Book. The one notable exception is Yahoo!
    Mail, which Trillian will check periodically. If new mail arrives while
    you're using Trillian, it will display a new mail alert (like the one
    shown in Figure 3-41) .




    Figure 3-41. Trillian new mail notification





    Trillian users will also miss out on some Yahoo! Instant Messenger
    features, such as Audibles, which feature animated characters saying
    humorous phrases, and Trillian users won't see the animated avatars that
    show a cartoon-like representation of the chat participants.


    Beyond these differences, Trillian is a great way to stay in touch with
    people if their favorite instant messenger isn't the same as yours.
















    Hack 67. Store, Sort, and Share Your Photos





    Flickr makes it easy to share your photos with the world.


    At its most basic, Flickr is a web application that helps you create a
    public journal of photos. You can upload your photos to Flickr and see
    them appear on a web page with the most recently added photo on top. But
    once you start playing with Flickr, you'll quickly find that it's much
    more sophisticated. In fact, Flickr is an open platform for storing,
    arranging, sharing, discussing, and discovering photos with people across
    the globe.


    What began as an independent project by a small company called Ludicorp
    was recently purchased by Yahoo! and is in the process of being integrated
    more closely with Yahoo!. At the time of this writing, Flickr is still
    very much an independent application, and you'll need your own Flickr
    account to upload photos (a Yahoo! ID will not work). You can create a
    free Flickr account by browsing to http://www.flickr.com/ and clicking the
    pink "Sign up now!" button.




    A basic Flickr account is free, lets you upload up to 20 MB in
    photos per month, show up to 200 of your photos, and create
    three individual galleries (which Flickr calls sets). You can
    also upgrade to a paid Flickr Pro account, which gives you
    much more storage and unlimited sets. At the time of this
    writing, a Flickr Pro account is $24.95 per year.






    Once you've created an account, you can add some information about
    yourself to your profile that will tell others a bit about you. Flickr is
    a social application, and unlike some sites where uploading photos feels
    like a lonely process, adding photos to Flickr feels like a group
    activity.


    3.18.1. Store


    The first step in getting to know Flickr is to upload some of your photos.
    The steps required to move photos from your camera to your computer vary
    widely, so that will have to be left as an exercise for the reader. But
    once photos are on your computer, there are several ways to move them to
    Flickr.


    3.18.1.1. From your browser.


    The simplest way to upload photos is via your web browser and the "Upload
    Photos to Flickr" page (http://www.flickr.com/photos/upload). Click
    Browse… next to one of the blank fields on the page, and a new window will
    let you choose an image file on your local computer. Figure 3-42 shows
    what choosing a file looks like on Windows XP.


    When you highlight a photo and click Open, the previously blank field will
    be filled in with the local path to the image file. You can upload up to
    six photos at a time and set tags and privacy settings for each photo in
    the group. Clicking Upload sends your photos to Flickr, which might take
    some time, depending on the size of your photos and your connection speed.
    Once your photos have been uploaded, you'll have the option to add titles
    and descriptions to each of them. It's easy to add titles and descriptions
    later as well.




    Figure 3-42. Choosing photos to upload to Flickr





    You can set default privacy options for every photo you upload, by
    clicking Your Account from the top of any Flickr page and choosing Default
    Photo Privacy from the menu. Or you can browse directly to
    http://www.flickr.com/profile_photoconf.gne to set options such as who can
    see your photos, who can comment, and who can add notes and tags.


    3.18.1.2. From your desktop.


    Once you're completely hooked on Flickr, you might want to upload entire
    sets of photographs at a time. You can find a number of ways to upload
    photos on the Tools page (http://www.flickr.com/tools). The tools are
    programs you can download and install on Windows or Macintosh computers
    that allow you to upload a number of photos at once. Figure 3-43 shows the
    Windows Flickr Uploadr in action; you can simply drag images from the
    Windows File Explorer and drop them onto the Flickr Uploadr window.


    Once you've added all of the photos you want to send to Flickr into the
    Flickr Uploadr, click the Upload… button. You'll also have the option to
    add tags to the photos or change the default privacy settings for those
    photos.




    Figure 3-43. Adding photos from the desktop with Flickr Uploadr





    3.18.1.3. From an email address.


    In addition to uploading photos via the Webor a desktop application, you
    can send photos to Flickr by email. Click the Your Account link from the
    top of any Flickr page and choose "Uploading photos by email" under the
    Photo Settings heading. You can also browse directly to
    http://www.flickr.com/profile_mailconf.gne.


    Once there, you'll find a randomly generated email address that's unique
    to your Flickr account. You can use the address to send photos to Flickr
    as email attachments. This option is particularly handy for cell phone
    cameras, because you can snap your photo on the go and post it directly to
    Flickr without making a trip to your home computer.


    3.18.2. Sort


    You'll find every photo you upload in your Flickr photostream. A
    photostream is simply a list of every photo you've uploaded in
    reverse-chronological order (i.e., the photo you uploaded most recently is
    listed first). And once your photos are in your photostream, there are a
    number of ways you can organize them beyond the chronological listing.


    3.18.2.1. Tagging.


    Tagging is a simple form of organization that lets you associate keywords
    with each of your photos. Unlike traditional categorization schemes, tags
    are free-form: you can use any words, numbers, or phrases you like. Figure
    3-44 shows a photo at Flickr with its tags listed just to the right of the
    photo.




    Figure 3-44. A photo with tags at Flickr





    The photo was taken in the town of Kaneohe, Hawaii, at a Buddhist temple,
    and the photographer has tagged the photo with the words temple, Kaneohe,
    and Hawaii. By clicking any tag, you'll see all of your photos tagged with
    that particular word. And by clicking the globe icon next to any tag,
    you'll see photos by everyone at Flickr tagged with that word.


    3.18.2.2. Organizing.


    The key to more complex organization is the Flickr tool called Organizr.
    Organizr runs in your browser and you'll need the free Macro-media Flash
    Player (http://www.macromedia.com/go/getflashplayer) installed to use it.
    You can fire up Organizr by clicking the Organize link at the top of any
    Flickr page.


    Inside Organizr, you'll find your photos in the main window. You can view
    all photos, limit your photos by date, or search your titles,
    descriptions, and tags. The sliders below the main window adjust the dates
    you'd like to view (see Figure 3-45).




    Figure 3-45. Sorting photos with Flickr Organizr





    Inside Organizr, you can create and edit photo sets. A set is group of
    photos that you assemble into an individual gallery. Once you've created a
    set and given it a title, you can drag a photo from the main window and
    drop it into a set on the right to add the photo to the set. From there,
    you can arrange the photos in a set into a specific order. Figure 3-46
    shows what the cover page of a set looks like to someone browsing a set
    for the first time.




    Free Flickr accounts are limited to three sets, but you can
    create an unlimited number of sets with a Flickr Pro account.






    The "View as slideshow" link on the front page of a set will let someone
    see the group of photos as Flash presentation. Viewers don't even have to
    type on the keyboard or click their mouse; they can sit back and watch the
    photos dissolve in and out as the presentation automatically moves from
    one picture to the next.


    3.18.3. Share


    One of the primary benefits of using Flickr is that once your photos are
    uploaded, they are accessible to anyone with a web browser.




    Figure 3-46. A Flickr photoset





    3.18.3.1. Free to the public.


    The easiest way to share all of your photos is to create a simple URL,
    called a Flickr address, that you can share with others. Browse to
    http://www.flickr.com/profile_url.gne and choose a simple word as your
    address. The format of the URL will look like this:


    http://www.flickr.com/photos/insert your word




    It's important to choose your Flickr address carefully, because your
    choice is permanent; you can't edit your Flickr address once you've
    created it. The newly created URL will point directly to your photostream,
    and you can give the URL to your friends and family or link to your
    photostream from another web site using the URL.


    Once your photos are on Flickr, you can also share them by automatically
    posting them to a weblog [Hack #98] or by displaying your latest photos
    with a Flickr badge [Hack #99]. Flickr also provides RSS feeds for
    photostreams, groups, and tags, so once your photos are in the system,
    there are myriad ways for others to view them.


    One benefit of these methods of sharing is that others viewing your photos
    don't need to be members of Flickr to see them. They don't have to go
    through an account creation process simply to look at your photos. But if
    someone does go the extra mile to become a Flickr member, there are
    several more ways to connect and share photographs.


    3.18.3.2. Flickr community.


    Flickr works best when your friends and family are also participating at
    the site. Once someone has an account, you can add him as a friend, family
    member, or contact.




    Keep in mind that whichever category another Flickr member is
    in will determine which photos of yours she can see if you
    alter the default privacy settings for a particular photo.






    As you build a group of contacts at Flickr, you'll be able to easily
    browse their photos just as they can browse yours. Clicking the Your
    Contacts' link in the Photos: bar at the top of any Flickr page will show
    the latest photos added by all of your contacts, and it's a great way to
    keep up with your friends. You can also browse a full list of your
    contacts by clicking the People link at the top of any page and then
    clicking someone's name to see his photostream. Figure 3-47 shows a
    contact list at Flickr.




    Figure 3-47. A list of contacts at Flickr





    The Groups feature lets anyone form a public discussion and photo-sharing
    space at Flickr. In addition to sending photos to a group photo pool, you
    can post messages to the group and carry on a conversation. For example,
    there's a group called The Bookshelf Project
    (http://www.flickr.com/groups/bookshelf). The members there share photos
    of their home bookshelves and discuss the topic of storing books.


    If you're interested in a specific topic, chances are good that someone
    has created a specific Flickr Group devoted to it. You can browse a full
    list of groups, organized by topic, at
    http://www.flickr.com/groups_browse.gne. Figure 3-48 shows the Flickr
    Group for this book, which you'll find online at
    http://www.flickr.com/groups/yahoohacks.




    Figure 3-48. A Flickr Group page





    Flickr members can also comment on each other's photos, help out with
    tagging, and even add notes to specific areas of a photo. And, as always,
    these features are contingent on the permissions you set for your photos.



















    Chapter 4. Web Services


    Section 4.1. Hacks 6876: Introduction


    Section 4.2.


    Hack 68. Program Yahoo! with Perl


    Hack 69. Program Yahoo! with PHP 5


    Hack 70. Program Yahoo! with Python


    Hack 71. Program Yahoo! with VBScript


    Hack 72. Program Yahoo! with ColdFusion


    Hack 73. Program Yahoo! with XSLT


    Hack 74. Program Yahoo! with Java


    Hack 75. Program Yahoo! with Ruby


    Hack 76. Program Yahoo! with REBOL
















    4.1. Hacks 6876: Introduction


    As you've already seen, Yahoo! provides an impressive amount of
    information on its sites. And through the years, private hackers have
    found ways to use Yahoo! data in their scripts and programs. A search for
    Yahoo! in the Perl module repository CPAN (http://search.cpan.org/) will
    turn up hundreds of modules written by independent programmers who wanted
    to automate some piece of Yahoo! for their own purposes. Most of these
    Perl modules and any code in other languagesrely on screen scraping to
    fetch the data. That is, the program downloads a Yahoo! web page and picks
    through the HTML to find the interesting data. Screen scraping isn't a
    reliable way to fetch data, because a single change to the HTML means a
    change to the code is necessary to keep it working.


    In February 2005, Yahoo! opened up a much more reliable and developer
    friendly path to its data, giving outside developers, tinkerers, and
    Yahoo! customers programmatic access to some of the data available on
    Yahoo! sites. This means that if you want to integrate information you
    find on Yahoo! into your own applications or web sites, Yahoo! Web
    Services has opened the door for you.















    4.2.


    4.2.1. What Are Web Services?


    The term web service refers to a set of standards for exchanging data
    between two systems. Though the systems may be built with completely
    different platforms, the web service protocols allow the systems to
    exchange information. For example, a service built with Perl scripts on a
    Linux machine could exchange information with a Visual Basic application
    on a Microsoft computer because both platforms can speak the common web
    service language.




    Sometimes a web service is referred to as an application
    programming interface (API), a similar pre-Web concept. The
    terms are used interchangeably throughout this book.






    The phrase web service has also come to describe a specific method of
    exchanging data using XML files sent over the familiar HTTP protocol. XML
    is a textual, structured representation of data that both computers and
    humans can read, and HTTP is the standard protocol for delivering content
    across the Web. Yahoo! has implemented a straightforward XML over HTTP
    architecture for its web services.


    4.2.2. Yahoo! Web Services


    Yahoo! has chosen a web services standard called REST for delivering most
    of its data. If you've used the Web, you'll be familiar with how REST
    works. A specially constructed URL will return the data you're afterjust
    as the URL for a document on the Web returns that document. Instead of a
    web page (HTML document), REST requests return an XML document. The key to
    using Yahoo! Web Services is learning how to construct the proper request
    URLs.


    Before creating your own request URLs though, it'd be good to know exactly
    what you can get your hands on through the API.


    4.2.2.1. What's Available


    Not every piece of data available at Yahoo! is available via web services.
    For example, movie showtimes [Hack #42] and television schedules [Hack
    #44] are still limited to the Web. But you can get access to Yahoo! Search
    results and a few services that aren't available via the Web.


    The list of web services that Yahoo! provides is continually evolving, and
    you should browse to the Yahoo! Developer Network
    (http://developer.yahoo.net/) to keep up with additions and changes. At
    the time of this writing, the services available include:




    Search


    As you'd expect, you can access search results across the Web, Image,
    Local, News, Video, Audio, Shopping, and Contextual [Hack #97] Searches.




    Text Analysis


    In addition to the search results, you can access some features of the
    Yahoo! Search pages including Related Queries and Spelling Suggestions.
    You can also access the Content Analysis feature that extracts keywords
    from text.




    My Web


    You can access information from Yahoo!'s My Web [Hack #7], giving you the
    ability to integrate your saved pages into other applications.




    Maps


    By specifying the URL of a geo-encoded RSS file, you can plot your own
    points [Hack #91] on an interactive Yahoo! Map.




    Flickr


    Purchased by Yahoo! in 2005, Flickr [Hack #67] joined the Yahoo! family
    with a fully realized web services offering of its own. You can use the
    Flickr API to programmatically access every facet of the photo-sharing
    service from adding photos to browsing information about Flickr members.




    RSS


    While RSS is not technically a web service, it's important to keep in mind
    that Yahoo! offers RSS feeds across their sites, and the feeds provide a
    simple way to integrate data with your web site.


    Along with offering web services, Yahoo! has started a conversation with
    developers at the Yahoo! Developer Network. Browse to the Community
    Resources page (http://developer.yahoo.net/community) to see how other
    developers are using Yahoo! data in their applications.


    4.2.2.2. Yahoo!'s Terms


    Yahoo! has made this data available for free, but there are a few rules
    you have to play by to keep your access to the data. The key rule to keep
    in mind is that Yahoo! data can't be used in commercial applications. That
    means you can't use the API in an application you plan to sell or on a web
    site you charge people to access. Yahoo! also asks that you add
    attribution somewhere in your application. Adding the phrase "Powered by
    Yahoo! Search" to a site that uses Yahoo! data will fulfill the
    requirement.




    If you're a lawyer (or think like one) you can read the
    complete Yahoo! APIs Terms of Use at
    http://developer.yahoo.net/terms.






    If the API is free, what's in it for Yahoo!? Yahoo! Search Evangelist
    Jeremy Zawadony said, "By exposing interesting pieces of Yahoo! to the
    larger developer community, we think they'll build applications that
    benefit both us and our users." In addition to showing you some basic code
    to access Yahoo! in various programming languages, this chapter will show
    you some of the applications that outside developers are building with
    Yahoo! data.


    4.2.2.2.1. Request limits.


    Yahoo! imposes some limits on the number of requests that can be made per
    day. The request limit can vary by service, but at the time of this
    writing, you're limited to 5,000 queries per day for most services. Yahoo!
    tracks usage by IP address (a numeric address for every machine connected
    to the Internet), so a single machine can't make more than 5,000 requests
    in a single day.


    If you ever reach the limit, you'll receive an HTTP 403 "Forbidden" error
    that indicates you're over your limit for the day.


    4.2.2.2.2. Application IDs.


    Yahoo! also requires that for every application you build, you include an
    ID unique to the application with every request the application makes. You
    can request a unique ID at any time by browsing to
    http://api.search.yahoo.com/webservices/register_application. You'll need
    to be logged in with your Yahoo! ID to request an application ID.


    Keep in mind that Yahoo! doesn't use application IDs to monitor request
    limits; the ID is simply used to track your application usage. In turn,
    Yahoo! provides the usage data for your application IDs at
    http://api.search.yahoo.com/webservices/register_application. Figure 4-1
    shows the Application ID report available at the Yahoo! Developer Network.




    Figure 4-1. Application ID Usage page





    4.2.2.3. Making Requests


    Now that you know the rules, you can start making Yahoo! Web Service
    requests by assembling URLs for the different services.


    4.2.2.3.1. Search and Text.


    The Search, Text, and My Web services all use the same structure for
    request URLs. The URL starts with the base service URL,
    http://api.search.yahoo.com/. From there, you add a service name, version
    number, and specific function to the URL. Calling the Web Search (
    webSearch) function of the Web Search service (WebSearchService) looks
    like this:


    http://api.search.yahoo.com/WebSearchService/V1/webSearch




    At the time of this writing, all Yahoo! Search services are in Version 1,
    so the V1 parameter will be consistent throughout. As Yahoo! upgrades the
    service in the future, this parameter might change.


    The final step to assembling the proper URL is adding parameters to the
    query. The only parameters required for a web search are appid and query,
    so a Web Search request could be as simple as:


    http://api.search.yahoo.com/WebSearchService/V1/webSearch?app

    id=insert app



    ID&query=insert query




    Once you have the query built, you can even plug the URL in your browser's
    address bar to bring up the response XML and see exactly which information
    you'll receive. Figure 4-2 shows a Yahoo! Search response for the term
    hacks in a browser.


    Every Yahoo! service contains a different set of potential request
    parameters you can use to modify your requests. For example, the Yahoo!
    Web Search service allows you to filter searches by language (language),
    country (country), adult content ( adult_ok), document type (type), or
    Creative Commons license (license). Each service also has parameters for
    controlling the page of the response. Just as the Web Search lists
    responses across a number of pages, Yahoo! Search Web Services also breaks
    the responses into pages. You can adjust the response by specifying the
    number of results (results) up to 50 per page and specifying the result
    position (start) the current page should start with.


    You can read the full documentation and find all of the parameters
    available for each of the services at the developer site
    (http://developer.yahoo.net/).


    4.2.2.3.2. Maps.


    To create your own map with custom points, you'll need an application ID
    and the URL of a specially prepared RSS file on your own server. You can
    assemble these pieces into a URL like this:


    http://api.maps.yahoo.com/Maps/V1/AnnotatedMaps?appid=insert app



    ID&xmlsrc=insert RSS url






    Figure 4-2. A response from Yahoo! Web Search Services





    The Maps API is a bit different because you're receiving not XML, but a
    fully realized HTML document. You'll find a custom map example [Hack #91]
    in Chapter 5.


    4.2.2.3.3. Flickr.


    At the time of this writing, the Flickr API operates under different rules
    from other Yahoo! Search APIs. You'll need to request a Flickr API Key at
    http://www.flickr.com/services/api/key.gne to make requests, and you have
    the option of using a REST, XML-RPC, or SOAP interface for the requests.
    You can find a complete list of API methods available for Flickr at
    http://www.flickr.com/services/api.


    4.2.2.3.4. RSS.


    You'll find Yahoo! RSS documents throughout Yahoo! sites, and you don't
    need anything extra to use them. Simply copy the RSS URL and paste it into
    your favorite RSS newsreader, or integrate the files with your own web
    sites. Yahoo! doesn't limit access or require an application ID to use
    RSS, and the feeds aren't covered by the Yahoo! Web Services terms of
    service.


    4.2.2.4. Working with Responses


    The way to parse XML responses will be unique to your development
    environment, and this chapter provides basic examples in nine different
    languages. Typically, you'll need two pieces of software that aren't
    always built into your environment of choice: code to handle HTTP requests
    and code to parse XML responses.


    Yahoo! responses are in a proprietary XML format that's unique to the
    Yahoo! APIs. The top-level tag in Yahoo! Search API responses is
    , with a number of tags holding information about each
    individual result.


    Each result detail will vary by service, but typically you'll receive all
    of the data necessary to duplicate what you find on the corresponding
    Yahoo! site. For example, each Web Search result includes the following
    XML tags: , <Summary>,< Url>, <ClickUrl>, <MimeType>, <br /> <ModificationDate>, and <Cache>. As you can tell from the tag names, the <br /> data you'll receive is almost identical to the data on a Yahoo! Web Search <br /> results page outlined in the introduction to Chapter 1.<br /><br /><br /> The key to understanding what's available and how you can use it is simply <br /> playing with data and building some sample applications. The hacks in this <br /> chapter should give you a head start on integrating Yahoo! data into your <br /> own programs.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 68. Program Yahoo! with Perl<br /><br /><br /><br /><br /><br /> Grabbing data from Yahoo! Search Web Services can be quite easy with just <br /> a little bit of Perl.<br /><br /><br /> Perl is great for getting things done quickly, and fetching search results <br /> from Yahoo! is no exception. This hack shows a simple way to access Yahoo! <br /> with Perl, using minimal code. Think of it as a doorway to Yahoo! that you <br /> can drop into your own Perl scripts, or that you can use as a starting <br /> point for more complex applications. This script will accept a keyword or <br /> phrase, contact Yahoo! Search, and print out the first 10 results.<br /><br /><br /> 4.3.1. <br /><br /><br /> 4.3.1.1. What You Need<br /><br /><br /> In the spirit of keeping things easy, this hack uses two simple modules <br /> that may already be installed on your system: LWP::Simple <br /> (http://search.cpan.org/~gaas/libwww-perl-5.803/lib/LWP/Simple.pm) makes <br /> the HTTP request; XML::Simple <br /> (http://search.cpan.org/~grantm/XML-Simple-2.14/lib/XML/Simple.pm) parses <br /> the XML response. If you need to install these modules, you can use CPAN <br /> for each module:<br /><br /><br /> perl MCPAN e shell<br /> cpan> install XML::Simple<br /><br /><br /><br /><br /> On a Windows system with ActivePerl, you can install these modules from <br /> the command line with the Perl package manager, like this:<br /><br /><br /> ppm install LWP-Simple<br /><br /><br /><br /><br /> The only other piece you'll need is a unique application ID from Yahoo!, <br /> which you can pick up at <br /> http://api.search.yahoo.com/webservices/register_application.<br /><br /><br /> 4.3.1.2. The Code<br /><br /><br /> This code builds a Yahoo! Search Web Services request URL using the <br /> keyword passed to it when the script is run. Then it parses the response <br /> and prints it out in a readable format. Save the following code to a file <br /> named yahoo_search.pl:<br /><br /><br /> #!/usr/bin/perl<br /> # yahoo_search.pl<br /> # Accepts a search term and shows the top results.<br /> # Usage: yahoo_search.pl <Query><br /> #<br /> # You can create an AppID, and read the full documentation<br /> # for Yahoo! Web Services at http://developer.yahoo.net/<br /><br /><br /> use strict;<br /> use LWP::Simple;<br /> use XML::Simple;<br /><br /><br /> # Set your unique Yahoo! Application ID<br /> my $appID = "insert your app ID";<br /><br /><br /> # Grab the incoming search query <br /> my $query = join(' ', @ARGV) or die "Usage: yahoo_search.pl <query>\n";<br /> # Construct a Yahoo! Search Query with only required options<br /> my $language = "en";<br /> my $req_url = "http://api.search.yahoo.com/";<br /><br /><br /> $req_url .= "WebSearchService/V1/webSearch?";<br /> $req_url .= "appid=$appID";<br /> $req_url .= "&query=$query";<br /> $req_url .= "&language=$language";<br /><br /><br /> # Make the request<br /> my $yahoo_response = get($req_url);<br /><br /><br /> # Parse the XML<br /> my $xmlsimple = XML::Simple->new();<br /> my $yahoo_xml = $xmlsimple->XMLin($yahoo_response);<br /><br /><br /> # Initialize results counter<br /> my $i;<br /><br /><br /> # Loop through the items returned, printing them out<br /> foreach my $result (@{$yahoo_xml->{Result}}) {<br /> $i++;<br /> my $title = $result->{Title};<br /> my $summary = $result->{Summary};<br /> my $url = $result->{Url};<br /> print "$i. $title\n$summary\n$url\n\n";<br /><br /><br /> }<br /><br /><br /><br /><br /> The final print command sends the information from Yahoo! to STDOUT. You <br /> can change what this script shows by rearranging the variables and making <br /> this last line more or less complex.<br /><br /><br /> 4.3.1.3. Running the Hack<br /><br /><br /> Simply call the script from the command line:<br /><br /><br /> perl yahoo_search.pl insert word<br /><br /><br /><br /><br /> And be sure to enclose phrases or multiple keywords in quotes:<br /><br /><br /> perl yahoo_search.pl "insert multiword phrase"<br /><br /><br /><br /><br /> Figure 4-3 shows the Yahoo! Search results for the phrase "minimalist <br /> Perl".<br /><br /><br /><br /><br /> Figure 4-3. Yahoo! Search results for "minimalist Perl"<br /><br /><br /><br /><br /><br /> This hack uses minimalist Perl to demonstrate how quickly Yahoo! data can <br /> be included in Perl scripts, and this technique can be used as a building <br /> block for more advanced scripts. In fact, most of the Perl scripts in this <br /> book use this basic method of accessing Yahoo! Search Web Services.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 69. Program Yahoo! with PHP 5<br /><br /><br /><br /><br /><br /> Take advantage of some of the latest features in PHP to quickly add Yahoo! <br /> data to PHP-powered pages.<br /><br /><br /> The recursively named PHP Hypertext Processor language is a popular choice <br /> for building dynamic web applications. In fact, Yahoo! itself has made PHP <br /> its development platform of choice across the company. The PHP platform is <br /> continually evolving, and the latest version (Version 5) includes a handy <br /> XML parser called SimpleXML. As the name implies, it's easy to work with. <br /> And as long as the XML that SimpleXML is parsing is fairly simple, it's <br /> the perfect tool for getting XML data into objects PHP can easily <br /> manipulate.<br /><br /><br /> Yahoo! Search Web Services responses definitely qualify as simple XML, and <br /> this hack shows how easy it is to request and parse this data with PHP. <br /> You'll need PHP 5 for this hack, but you won't need any external modules.<br /><br /><br /> 4.4.1. The Code<br /><br /><br /> Save the following code to your web server in a file called <br /> yahoo_search.php.<br /><br /><br /><br /><br /> Don't forget to grab a unique application ID for this script <br /> at http://developer.yahoo.net/.<br /><br /><br /><br /><br /><br /><br /> <?php<br /> // yahoo_search.php<br /> // Accepts a search term and shows the top results.<br /> // Usage: yahoo_search.php?p=<Query><br /> //<br /> // You can create an AppID, and read the full documentation<br /> // for Yahoo! Web Services at http://developer.yahoo.net/<br /><br /><br /> // Set your unique Yahoo! Application ID<br /> $appID = "insert your app ID";<br /><br /><br /> // Grab the incoming search query, and encode for a URL<br /> $query = $_GET['p'];<br /> $query = urlencode($query);<br /><br /><br /> if ($query == "") { <br /> print "usage: yahoo_search.php?p=<Query>"; die;<br /> }<br /><br /><br /> // Construct a Yahoo! Search Query with only required options<br /> $language = "en";<br /> $req_url = "http://api.search.yahoo.com/";<br /> $req_url .= "WebSearchService/V1/webSearch?";<br /> $req_url .= "appid=$appID";<br /> $req_url .= "&query=$query";<br /> $req_url .= "&language=$language";<br /><br /><br /> // Make the request<br /> $yahoo_response = file_get_contents($req_url);<br /><br /><br /> // Parse the XML<br /> $xml = simplexml_load_string($yahoo_response);<br /><br /><br /> // Initialize results counter<br /> $i = 0;<br /> ?><br /> <html><br /><br /><br /> <body><br /> <h2>Yahoo! Search Results</h2><br /> <ol><br /> <? php<br /> // Loop through the items returned, printing them out<br /> foreach ($xml->Result as $result) {<br /> $i++;<br /> $title = $result->Title;<br /> $summary = $result->Summary;<br /> $summary = preg_replace("/</i","<",$summary);<br /> $clickurl = $result->ClickUrl;<br /> $url = $result->Url;<br /> print "<li><div style=\"margin-bottom:15px;\">";<br /> print "<a href=\"$clickurl\">$title</a><br />";<br /> print "$summary<br />";<br /> print "<cite>$url</cite></div></li>\n";<br /><br /><br /> }<br /> ?><br /> </ol><br /> -- Results Powered by Yahoo!<br /> </body><br /> </html><br /><br /><br /><br /><br /> This script uses the value of the querystring variable p to build a Yahoo! <br /> Web Search request URL and fetches the XML with the file_get_contents() <br /> function. Once the script has the XML in the $yahoo_response string, it <br /> calls the SimpleXML function simplexml_load_string( ), which parses the <br /> XML and makes the data available to PHP as an object. Finally, the script <br /> loops through the objects, using print to send the data to the browser.<br /><br /><br /> 4.4.2. Running the Hack<br /><br /><br /> To run the script, point your web browser to the location of the script on <br /> your server and add the querystring variable p:<br /><br /><br /> http://example.com/yahoo_search.php?p=insert word<br /><br /><br /><br /><br /> You can add multiple words by encoding spaces for URLs. For example, <br /> here's the search string for "PHP encoding":<br /><br /><br /> http://example.com/yahoo_search.php?p=PHP%20encoding<br /><br /><br /><br /><br /> Figure 4-4 shows the results of a search for simpleXML.<br /><br /><br /> As the results indicate, you can read the official documentation for PHP's <br /> SimpleXML function at http://www.php.net/simplexml. With this function, <br /> working with Yahoo! Search Web Services data is much more intuitive than <br /> with earlier versions of PHP.<br /><br /><br /><br /><br /> Figure 4-4. Yahoo! Search results for "simpleXML"<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 70. Program Yahoo! with Python<br /><br /><br /><br /><br /><br /> Use the existing Yahoo! library for Python to build applications quickly.<br /><br /><br /> The Yahoo! Developer Network web site (http://developer.yahoo.net/) <br /> provides a number of tools to help developers build applications with <br /> Yahoo! data. Their Yahoo! Search Web Services software development kit <br /> (SDK) includes a handy Python library called pYsearch that does most of <br /> the heavy lifting (making requests and parsing responses) for you. This <br /> means you have a simple set of commands to learn and interact with, rather <br /> than having to take the time to learn how Yahoo! request URLs should be <br /> formatted. In exchange for this ease of use, you'll need to spend a few <br /> minutes installing the library.<br /><br /><br /> Download the SDK (at http://developer.yahoo.net/download) and unzip its <br /> contents to install the pYsearch library. From a command prompt, change <br /> directories to the newly unzipped SDK files and then change into the <br /> /python/pYsearch directory. In this directory, you'll find setup.py, which <br /> you'll need Python 2.2.3 to run. If you can't install a newer version, or <br /> if you'd rather not, there's a quick way to make the library compatible <br /> with older versions of Python. Just add the following code to setup.py, <br /> toward the top of the script:<br /><br /><br /> # add for Python versions that don't understand "classifiers"<br /> import sys<br /> if sys.version < '2.2.3':<br /> from distutils.dist import DistributionMetadata<br /> DistributionMetadata.classifiers = None<br /> DistributionMetadata.download_url = None<br /><br /><br /><br /><br /> Once setup.py is ready to go for your system, install it from the command <br /> prompt with these two commands:<br /><br /><br /> python setup.py build<br /> python setup.py install<br /><br /><br /><br /><br /> If everything works as it should, the pYsearch library will now be <br /> available to your Python scripts.<br /><br /><br /> 4.5.1. The Code<br /><br /><br /> This simple Python script uses the pYsearch library to return Yahoo! Web <br /> Search responses. Save this code to a file called yahoo_search.py and be <br /> sure to add your own unique application ID:<br /><br /><br /> #!/usr/bin/python<br /> # yahoo_search.py<br /> # A quick Yahoo! Web Search script using Yahoo!'s<br /> # pYsearch library availble in the Y!WS SDK<br /> # [http://developer.yahoo.net/download/]<br /> # Usage: python yahoo_search.py <Query><br /><br /><br /> import sys, string, codecs<br /><br /><br /> # Use the pYsearch functions<br /> from yahoo.search import webservices<br /><br /><br /> # Grab the query from the command line<br /> if sys.argv[1:]:<br /> query = sys.argv[1]<br /> else:<br /> sys.exit('Usage: python yahoo_search.py <query>')<br /><br /><br /> # Include your unique application ID<br /> appID = 'insert your app ID'<br /><br /><br /> # Query Yahoo!<br /> search = webservices.create_search('web', appID)<br /> search.language = "en"<br /> search.results = 10<br /> search.start = 1<br /> search.query = query<br /><br /><br /> # Parse the results<br /> try:<br /><br /><br /> results = search.parse_results()<br /> except Exception, err:<br /> print "Got an error: ", err<br /> sys.exit(1)<br /><br /><br /> # Tell standard output to handle utf-8 encoding<br /> sys.stdout = codecs.lookup('utf-8')[-1](sys.stdout)<br /><br /><br /> # Start counter<br /> count = search.start<br /><br /><br /> # Print out the results<br /> for result in results:<br /> print "%s. %s\n%s\n%s\n\n" % (count, result.Title, result.Summary,<br /><br /> result.Url)<br /> count += 1<br /><br /><br /><br /><br /> The key to using the pYsearch library is importing the webservices module <br /> at the top of the script. From there, the script calls the create_search <br /> function, sets some parameters, and uses parse_results to get the entire <br /> Yahoo! response. And the last print command formats the response and <br /> displays it for the user.<br /><br /><br /> The web search type is specified in the create_search function, but keep <br /> in mind that you could use any of Yahoo!'s search services here.<br /><br /><br /> 4.5.2. Running the Hack<br /><br /><br /> Run the script on the command line:<br /><br /><br /> python yahoo_search.py insert word<br /><br /><br /><br /><br /> And, as usual, enclose multiple words in quotation marks:<br /><br /><br /> python yahoo_search.py "insert multiword phrase"<br /><br /><br /><br /><br /> Figure 4-5 shows the results for "learning Python".<br /><br /><br /> Python is known as a language that can assemble complex applications <br /> quickly; if you're planning to integrate Yahoo! data with a Python <br /> application, it's that much faster because most of the hard work is done <br /> for you already in the pYsearch library.<br /><br /><br /><br /><br /> Figure 4-5. Yahoo! Search results for "learning Python"<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 71. Program Yahoo! with VBScript<br /><br /><br /><br /><br /><br /> Build Yahoo! searches into Windows programs or ASP pages with VBScript.<br /><br /><br /> VBScript is a general-purpose scripting language for Windows, and it gets <br /> its name from Visual Basic, its big brother of a programming language. <br /> With a few tweaks here and there, the code in this hack could add Yahoo! <br /> searching to Office applications or an ASP-powered web page. This hack is <br /> written to run as a Microsoft Windows Script and it provides just the <br /> basics for building a Yahoo! Search query and presenting the results.<br /><br /><br /> Microsoft Windows Script is built into the fabric of the Windows operating <br /> system and is used primarily by system administrators to automate some <br /> tasks involved withyou guessed itsystem administration. But Microsoft <br /> Windows Scripts can also be used to automate applications and send data <br /> back and forth between programs.<br /><br /><br /> 4.6.1. What You Need<br /><br /><br /> If your Windows installation is up-to-date, you shouldn't need to install <br /> anything extra to run this hack. But if it's been a while since you've run <br /> Windows Update, you might want to grab the latest version of Microsoft <br /> Windows Script at http://www.microsoft.com/scripting. From that page, <br /> click Downloads and choose Microsoft Windows Script 5.6 or later for your <br /> version of Windows.<br /><br /><br /> This hack also relies on the Microsoft XML Parser to sort the results from <br /> Yahoo!. Your system should already have a version of the parser installed, <br /> but if you run into trouble, you can always download the latest version at <br /> http://msdn.microsoft.com/xml. Once you're there, click XML Downloads and <br /> choose the latest XML Core Services package you can find.<br /><br /><br /><br /><br /> As always, be sure to grab a unique Yahoo! application ID for <br /> this script at <br /> http://api.search.yahoo.com/webservices/register_application.<br /><br /><br /><br /><br /><br /><br /> 4.6.2. The Code<br /><br /><br /> Like any other script, the code is simply plain text in a standard text <br /> file. You could even use Notepad to save the following code to a file <br /> called yahoo_search.vbs:<br /><br /><br /> ' yahoo_search.vbs<br /> ' Accepts a search term and shows the top results.<br /> ' Usage: cscript yahoo_search.vbs <Query> //I<br /> '<br /> ' You can create an AppID, and read the full documentation<br /> ' for Yahoo! Web Services at http://developer.yahoo.net/<br /><br /><br /> 'Set your unique Yahoo! Application ID<br /> Const APP_ID = "insert your app ID"<br /><br /><br /> 'Grab the incoming search query or ask for one<br /> If WScript.Arguments.Length = 0 Then<br /> strQuery = InputBox("Enter a search Term")<br /> Else<br /> strQuery = WScript.Arguments(0)<br /> End If<br /><br /><br /> 'Construct a Yahoo! Search Query<br /> strLanguage = "en"<br /> strReqURL = "http://api.search.yahoo.com/" & _<br /> "WebSearchService/V1/webSearch?" & _<br /> "appid=" & APP_ID & _<br /> "&query=" & strQuery & _<br /> "&language=" & strLanguage<br /><br /><br /> 'Start the XML Parser<br /> Set MSXML = CreateObject("MSXML.DOMDocument")<br /><br /><br /> 'Set the XML Parser options<br /> MSXML.Async = False<br /><br /><br /> 'Make the Request<br /> strResponse = MSXML.Load(strReqURL)<br /><br /><br /> 'Make sure the request loaded<br /> If (strResponse) Then<br /><br /><br /> 'Load the results<br /> Set Results = MSXML.SelectNodes("//Result")<br /><br /><br /> 'Loop through the results <br /> For x = 0 to Results.length - 1<br /> strTitle = Results(x).SelectSingleNode("Title").text<br /> strSummary = Results(x).SelectSingleNode("Summary").text<br /> strURL = Results(x).SelectSingleNode("Url").text<br /> strOut = (x + 1) & ". " & _<br /> strTitle & vbCrLf & _<br /> strSummary & vbCrLf & _<br /> strURL & vbCrLf & vbCrLf<br /> WScript.Echo strOut<br /> Next<br /><br /><br /> 'Unload the results<br /> Set Results = Nothing<br /><br /><br /> End If<br /><br /><br /> 'Unload the XML Parser<br /> Set MSXML = Nothing<br /><br /><br /><br /><br /> This code accepts a query on the command line when the script runs, or it <br /> asks the user for a query with the InputBox( ) function. From there, the <br /> script uses the query to build the proper Yahoo! Web Search request. The <br /> results from the request are passed through the Microsoft XML Parser and <br /> formatted for display. WScript.Echo sends the results to the user.<br /><br /><br /> 4.6.3. Running the Hack<br /><br /><br /> There are a couple of different ways to run the code. The most useful way <br /> to see the results is to run the script from a command prompt in <br /> interactive mode. Open a command prompt and type the following command:<br /><br /><br /> cscript yahoo_search.vbs insert word //I<br /><br /><br /><br /><br /> Be sure to include multiword searches in quotes:<br /><br /><br /> cscript yahoo_search.vbs "insert multiword phrase" //I<br /><br /><br /><br /><br /> The //I switch tells Microsoft Windows Script to output any results to the <br /> command line. Figure 4-6 shows this in action for the search term <br />vbscript.<br /><br /><br /> If you want to, though, you can just double-click the yahoo_search.vbs <br /> file as you would any other program. You'll be prompted for a search word, <br /> and the results will be shown one at a timeall 10 of themin window prompts <br /> like the one shown in Figure 4-7.<br /><br /><br /> While this isn't the handiest way to view search results, it shows that <br /> adding Yahoo! data to VBScript applications can be accomplished fairly <br /> quickly.<br /><br /><br /><br /><br /> Figure 4-6. Yahoo! Search results for "vbscript"<br /><br /><br /><br /><br /><br /><br /><br /> Figure 4-7. The top Yahoo! Search result for "vbscript" in a window prompt<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 72. Program Yahoo! with ColdFusion<br /><br /><br /><br /><br /><br /> ColdFusion MX includes all of the tools necessary to work with the Yahoo! <br /> API.<br /><br /><br /> ColdFusion is a development platform for creating web applications. Its <br /> tag based template structure is a popular choice for HTML developers who <br /> want to move to more dynamic content and are already familiar with using <br /> tags. In fact, if you were to glance at a ColdFusion script, you might <br /> think the code was standard HTML. Putting together a ColdFusion template <br /> is a lot like putting together an HTML page, but you can draw on resources <br /> such as databases and web services to bring in dynamic content.<br /><br /><br /> You'll need to be running a version of ColdFusion MX or later to use this <br /> hack, because it relies on the XmlParse function that was added with the <br /> MX release. This function can take an XML document, such as the responses <br /> from Yahoo! Search Web Services, and turn it into an object that <br /> Cold-Fusion scripts can work with.<br /><br /><br /> 4.7.1. The Code<br /><br /><br /> This hack shows how you can quickly use the ColdFusion Markup Language ( <br /> CFML) to bring in content from Yahoo! Search Web Services. This script <br /> assembles the proper request URL based on a querystring variable and gets <br /> a response from Yahoo! with the <cfhttp> tag. Then the XmlParse function <br /> makes the data available to the script, and the <cfloop> tag goes through <br /> each bit of data, adding it to the page.<br /><br /><br /> Save the following code to a file called yahoo_search.cfm and upload it to <br /> your server:<br /><br /><br /> <!---<br /> yahoo_search.cfm<br /> Accepts a search term and shows the top results.<br /> Usage: yahoo_search.cfm?p=<Query><br /><br /><br /> You can create an AppID, and read the full documentation<br /> for Yahoo! Web Services at http://developer.yahoo.net/<br /> ---<<br /> <html><br /> <body><br /> <h2>Yahoo! Search Results</h2><br /> <ol><br /> <!--- Set your unique Yahoo! Application ID ---><br /> <cfset appID = "YahooTest"><br /><br /><br /> <!--- Grab the incoming search query ---><br /> <cfset query = "#URL.p#"><br /><br /><br /> <!--- Construct a Yahoo! Search Query with only required options ---><br /> <cfset req_url = "http://api.search.yahoo.com/"><br /> <cfset req_url = req_url & "WebSearchService/V1/webSearch?"><br /> <cfset req_url = req_url & "appid=#appID#"><br /> <cfset req_url = req_url & "&query=#query#"><br /> <cfset req_url = req_url & "&language=en"><br /><br /><br /> <!--- Make Request ---><br /> <cfhttp url="#req_url#" method="GET" charset="utf-8"><br /> <cfhttpparam type="Header" name="charset" value="utf-8" /><br /> </cfhttp><br /><br /><br /> <!--- Parse Response ---><br /> <cfset response = #XMLParse(cfhttp.fileContent)#><br /> <cfset results = #response.ResultSet.Result#><br /><br /><br /> <!--- Loop Through Response ---><br /> <cfoutput><br /> <cfloop from="1" to="#ArrayLen(results)#" index="i"><br /> <li><div style="margin-bottom:15px;"> <br /> <a href=\"#results[i].ClickUrl.xmlText#\">#results[i].Title.xmlText<br /> #</a>#results[i].Summary.xmlText#<br /> <br /> <cite>#results[i].Url.xmlText#</cite></div></li><br /> </cfloop><br /> </cfoutput><br /> </ol><br /> -- Results Powered by Yahoo!<br /> </body><br /> </html><br /><br /><br /><br /><br /> Take a look at the <cfhttp> tag in the script. Note that the charset <br /> attribute is utf-8 and that a <cfhttpparam> tag was used to set a charset <br /> header for the request with the utf-8 value. This is a bit of extra work, <br /> but it's necessary to make sure ColdFusion and Yahoo! Search Web Services <br /> are speaking the same language.<br /><br /><br /> 4.7.2. Running the Hack<br /><br /><br /> Bring up the page in a browser to see it in action:<br /><br /><br /> http://example.com/yahoo_search.cfm?p=insert word<br /><br /><br /><br /><br /> Separate multiple words with URL-encoded spaces, as in this search for " <br /> ColdFusion MX":<br /><br /><br /> http://example.com/yahoo_search.cfm?p=ColdFusion%20MX<br /><br /><br /><br /><br /> You should see the top Yahoo! Search results for ColdFusion MX, as shown <br /> in Figure 4-8.<br /><br /><br /><br /><br /> Figure 4-8. Yahoo! Search results for "ColdFusion MX"<br /><br /><br /><br /><br /><br /> As you can see, ColdFusion MX includes all of the tools you need to make <br /> Yahoo! Search Web Services requests and work with the responses. <br /> Integrating Yahoo! data with existing ColdFusion applications can be <br /> accomplished with just a few lines of code.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> Hack 73. Program Yahoo! with XSLT<br /><br /><br /><br /><br /><br /> Transform Yahoo! Search Web Services responses into HTML with an XSLT <br /> stylesheet.<br /><br /><br /> The Extensible Stylesheet Language (XSL) is a tag-based template system <br /> that can transform any XML document into any other text format, including <br /> other flavors of XML or, more commonly, HTML. Like a scripting language, <br /> XSL defines what data should go where on a page. You'll still need to use <br /> a scripting language to perform the transformation from XML into HTML, and <br /> the entire process is encapsulated in the term XSL transformations or <br />XSLT.<br /><br /><br /> At first glance, an XSL stylesheet looks a lot like an HTML page, and it <br /> often contains HTML tags. But unlike HTML, each stylesheet must be valid <br /> XML and must contain a number of tags that describe how the XML should be <br /> processed. While an HTML document can have a few unclosed tags here and <br /> there and still display a web page, XSL is very strict and will fail if <br /> it's not properly formed.<br /><br /><br /> Responses from the Yahoo! Search Web Services are in XML and can be <br /> transformed directly into an HTML page with a bit of XSL.<br /><br /><br /> 4.8.1. The Code<br /><br /><br /> Each stylesheet is organized into one or more templates that define how <br /> data from the source XML document should be arranged. The templates within <br /> a stylesheet contain a mix of XSL processing tags and HTML.<br /><br /><br /> To try a transformation out, first create the stylesheet. Save the <br /> following XSL to a text file called yahoo_search.xsl:<br /><br /><br /> <?xml version="1.0" encoding="UTF-8" ?><br /> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/<br /><br /><br /><br /> Transform"><br /> <xsl:template match="/"><br /> <html xmlns="http://www.w3.org/1999/xhtml"><br /> <head><br /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><br /> <title>Search Results




    Search Results







    Powered by Yahoo!


































  • In addition to the stylesheet, you'll need a scripting language to make
    the request and perform the transformation. Every development environment
    has XSLT tools you can use; this example uses Perl. As with most of the
    Perl examples in this book, you'll need the component LWP::Simple to make
    Yahoo! API requests. And to work with XSL, you'll need the XML::XSLT
    module.


    This script accepts a search query term, assembles the Yahoo! API request
    URL, and fetches the response. Then it uses the XML:: XSLT module to apply
    the stylesheet to the XML response and it prints the results. To create
    the script, save the following code to a file called yahoo_ xslt.cgi:


    #!/usr/bin/perl
    # yahoo_xslt.cgi
    # Accepts a search term and shows the top results.
    # Usage: yahoo_xslt.cgi?
    #
    # You can create an AppID, and read the full documentation
    # for Yahoo! Web Services at http://developer.yahoo.net/


    use strict;
    use XML::XSLT;
    use LWP::Simple;


    # Set the XSL stylesheet
    my $xslfile = "yahoo_search.xsl";


    # Set your unique Yahoo! Application ID
    my $appID = "insert Application ID";


    # Grab the incoming search query
    my $query = join(' ', @ARGV);
    unless ($query) {
    print "Content-type: text/plain\n\n";
    print "Usage: yahoo_xslt.cgi?query";


    exit;
    }


    # Construct a Yahoo! Search Query with only required options
    my $language = "en";
    my $req_url = "http://api.search.yahoo.com/";
    $req_url .= "WebSearchService/V1/webSearch?";
    $req_url .= "appid=$appID";
    $req_url .= "&query=$query";
    $req_url .= "&language=$language";


    # Make the request
    my $yahoo_response = get($req_url);


    # Transform the response
    my $ xslt = XML:: XSLT->new ($xslfile, warnings => 1);
    $ xslt->transform ($yahoo_response);


    # Print the transformation
    print "Content-Type: text/xml\n\n";
    print ' '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
    print $xslt->toString;


    # Clean up
    $xslt->dispose();




    4.8.2. Running the Hack


    To run the code, upload both files to a web server and bring up the script
    in a browser, adding a search term like this:


    http://example.com/yahoo_xslt.cgi?insert query




    So searching for the phrase "Elements of Style" looks like this:


    http://example.com/yahoo_xslt.cgi?Elements%20of%20Style




    Figure 4-9 shows the results of the script in a browser, with the XML
    formatted as HTML with the stylesheet.


    4.8.3. Hacking the Hack


    This example was written with Perl, but you could make Yahoo! API requests
    with your favorite development environment. If you were to re-create this
    example in PHP, Python, or Visual Basic, the XSL stylesheet would stay the
    same and only the script that makes requests and processes the
    transformation would change.




    Figure 4-9. Yahoo! Search API response transformed with XSLT



















    Hack 74. Program Yahoo! with Java





    Java's native support for working with XML makes parsing Yahoo! Search Web
    Services responses a snap.


    Simple REST, XML-over-HTTP interfaces like the one Yahoo! provides are
    most often associated with scripting languages such as Perl or PHP, while
    Javaa compiled languageis viewed as a better tool for working with more
    complex web services protocols. If Java is your preferred language, some
    new tools in the latest version have made it even easier to work with
    services like the Yahoo! API.


    Java 1.5 added native support for working with XML documents using XPath.
    This means that if you know the XML format ahead of time, you can retrieve
    a specific piece of the document with a simple query. For example, every
    Yahoo! response includes an attribute called totalResultsAvailable in the
    tag, which holds the value of the total number of results
    Yahoo! has for that particular query. If you'd like to grab this value
    with XPath, you can use this simple query:


    /ResultSet/@ totalResultsAvailable




    This hack presents a quick example using Java's built-in XML and XPath
    tools to work with Yahoo! Search Web Services. This native support means
    you won't need to download any external XML parsers; you simply need the
    latest version of Java.


    4.9.1. What You Need


    If you don't have Java 1.5 or higher, you'll need the latest Java
    Developer Kit ( JDK™), available at http://java.sun.com/. On the right
    side of the page, you'll find a section called Popular Downloads. Click
    the link for Java 2 Standard Edition (J2SE™) 5.0 and download the JDK.
    Don't confuse this with the Java Runtime Environment (JRE), because you'll
    need the complier included with the JDK.


    Once you've downloaded the file for your system, install the JDK and
    you'll be set to compile and run the hack.


    4.9.2. The Code


    This simple Java program accepts a query term, builds the appropriate
    Yahoo! Search Web Services URL with that term, and parses the response.
    Then the program lists the top 10 URLs for that search term. The code uses
    XPath queries to pick out the total results available and each URL in the
    response.


    Save the following code to a file called WebSearch.java and be sure to
    include a unique application ID:


    import org.w3c.dom.Document;
    import org.w3c.dom.Node;
    import org.w3c.dom.NodeList;
    import org.xml.sax.SAXException;


    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.xpath.XPath;
    import javax.xml.xpath.XPathConstants;
    import javax.xml.xpath.XPathExpressionException;
    import javax.xml.xpath.XPathFactory;
    import java.io.IOException;
    import java.io.UnsupportedEncodingException;
    import java.net.MalformedURLException;
    import java.net.URL;
    import java.net.URLEncoder;
    import java.text.MessageFormat;


    /**
    *Simple demonstration of the Yahoo! Web Search Service using Java 1.5's
    *XML support.
    */
    public class WebSearch {
    // Need to have an application ID to call the Yahoo! services.
    private static final String APPLICATION_ID = "insert app ID";


    // URL format for the request. The simplest request includes the
    // application ID and the query. See the service documentation for
    // a list of additional parameters.
    private static final String WEB_SEARCH_URL_FORMAT =
    "http://api.search.yahoo.com/WebSearchService/V1/



    webSearch?appid={0}&query={1}";
    /**


    *
    *Main program that takes a query and executes it as a web search
    *using the Yahoo! Web Search Service.
    *
    *@param args Command line arguments. There should be at least 1.
    */
    public static void main(String[] args) throws

    UnsupportedEncodingException,
    MalformedURLException, XPathExpressionException,
    ParserConfigurationException {
    // Make sure a query was given.
    String query = null;
    if(args.length == 0) {
    System.out.println("Usage: java WebSearch ");
    System.exit(1);
    }
    else {
    // Construct the query from the command line arguments.
    query = prepareQuery(args); }


    // Construct the URL. Inject the URL encoded application ID and
    // the search query.
    URL url = new URL(MessageFormat.format(WEB_SEARCH_URL_FORMAT,
    new Object[]{URLEncoder.encode(APPLICATION_ID, "utf-8"),
    URLEncoder.encode(query, "utf-8")}));
    System.out.println("Request URL = " + url.toString());


    // Create an XPath engine.
    XPath xpath = XPathFactory.newInstance().newXPath( );


    // Execute the query.
    Document responseDocument = null;
    try {


    // We need a Document to use XPath.
    DocumentBuilder builder = DocumentBuilderFactory.newInstance()

    .newDocumentBuilder();
    responseDocument = builder.parse(url.openStream());
    }
    catch (IOException e) {
    // Error calling the service.
    System.err.println("Error calling the service: " + e.toString(

    ));
    e.printStackTrace(System.err);
    System.exit(1);
    }
    catch (SAXException e) {
    // Error parsing the XML.
    System.err.println("Error parsing the XML: " + e.toString());
    e.printStackTrace(System.err);
    System.exit(1);


    }
    // Query the XML for the total results available.
    String totalResultsAvailable = (String) xpath.evaluate(
    "/ResultSet/@totalResultsAvailable",
    responseDocument,
    XPathConstants.STRING);
    System.out.println("Total results available for '" + query + "' is "
    + totalResultsAvailable);


    // Query the XML for the URLs.
    NodeList urls = (NodeList) xpath.evaluate("/ResultSet/Result/Url",
    responseDocument, XPathConstants.NODESET);
    for(int i = 0; i < urls.getLength(); i++) {
    Node urlNode = urls.item(i);
    System.out.println("URL " + (i + 1) + ": "
    + urlNode.getTextContent());
    }


    }
    /**
    * Simple method that stitches together an array of strings into
    * a single string. Used to take multiple command line arguments
    * and turn it into a single query string.
    *
    *@param args The individual strings to stitch together.
    *@return A new string containing each of the strings passed in, all
    *seperated by spaces.
    */
    private static String prepareQuery(String[] args) {
    String query;
    StringBuffer queryBuffer = new StringBuffer();
    for (int i = 0; i < args.length; i++) {
    queryBuffer.append(args[i]);
    if((i + 1) < args.length) {
    queryBuffer.append(" ");


    }
    }
    query = queryBuffer.toString();
    return query;


    }


    }




    To compile this code, open up a command prompt and type the following:


    javac WebSearch.java




    This should create the compiled WebSearch.class, which you can now run.


    4.9.3. Running the Hack


    From the same command prompt, you can run the code like so:


    java WebSearch insert term




    In response, the program shows the request URL it used, total results for
    that query, and the top 10 URLs. Figure 4-10 shows results for the term
    "Java XML".




    Figure 4-10. Yahoo! Search results for "Java XML"





    As you can see, handling REST queries and responses with Java is fairly
    quick work!


    Ryan Kennedy


















    Hack 75. Program Yahoo! with Ruby





    Use a Yahoo! Ruby library to include Yahoo! data in your Ruby scripts.


    The Yahoo! Developer Network web site (http://developer.yahoo.net/)
    provides a number of tools to help developers build applications with
    Yahoo! data. Their Yahoo! Search Web Services software development kit
    (SDK) includes libraries for various programming languages; Ruby,
    unfortunately, is not one of them. However, I have developed a Ruby
    library, which is available at
    http://premshree.seacrow.com/code/ruby/yahoo-ruby.


    The library is easy to use; there's no "installation" as such. Just copy
    the contents and place it in any suitable directory. The library is just
    one file, yahoo-ruby.rb, which you need to place in the lib/ruby/site_ruby
    directory of your Ruby installation. Once it is in place, whenever you
    want to use the Ruby API for Yahoo! Search Web Services, simply include
    require yahoo-ruby in the script. Using this Ruby library means you'll
    never have to know how to construct Yahoo! Search Web Services URLs, or
    even know what the XML looks like. The library handles all of the work of
    communicating with Yahoo!'s server.


    4.10.1. The Code


    This simple Ruby script uses the Ruby library to return Yahoo! Web Search
    responses. Save this code to a file called yahoo_search.rb and be sure to
    add your own unique application ID:


    #!/usr/bin/ruby
    # yahoo_search.rb
    # A simple Yahoo! search script using the
    # Ruby API (http://premshree.seacrow.com/code/ruby/yahoo-ruby)
    # Usage ruby yahoo_search.rb


    # include the yahoo-ruby API
    require 'yahoo-ruby'


    # get the query parameter
    query = ARGV[0]? ARGV[0] : exit


    ##
    # create a web search object:
    # Arguments:
    # 1. App ID (You can get one at http://developer.yahoo.net)
    # 2. The query
    # 3. type can be one of: 'all', 'any' or 'phrase'
    # 4. The no. of results
    ##
    obj = WebSearch.new('insert app ID', query, 'all', 3)


    # store the results -- returns an array of hashes
    results = obj.parse_results


    # now loop over each item in results, and display the title, summary and
    URL
    results.each { |result|
    print "Title:\t#{result['Title']}\n"
    print "Summary:\t#{result['Summary']}\n"
    print "URL:\t#{result['Url']}\n"
    print "=====================================\n\n"


    }




    The first thing this script looks for is the yahoo-ruby API. Then the
    script looks for the query argument; if an argument is not present, the
    script exits. After fetching the query from the command line, the script
    creates a WebSearch object and then calls the parse_results function to
    get the results as an array of hashes.


    To use a different Yahoo! Search serviceImage search, for exampleyou need
    to create a different object.


    4.10.2. Running the Hack


    Run the script on the command line:


    ruby yahoo_search.rb insert query




    So a search for the term ruby would look like this:


    ruby yahoo_search.rb ruby




    Figure 4-11. Yahoo! Search results for "ruby"




    Figure 4-11. shows the results of the search.





    As you can see, using the yahoo-ruby library means you can integrate
    Yahoo! data within your Ruby applications with a few lines of code.


    Premshree Pillai















    Hack 76. Program Yahoo! with REBOL





    With REBOL, you can build a graphical interface to Yahoo! with minimal
    code.


    Relative Expression-based Object Language (REBOL) is a technology that
    provides a lightweight method of distributed computing and communication.
    REBOL is a messaging language, which means it was built specifically to
    send messages across Internet protocols. REBOL is available for free, and
    there are two variations available for download:




    REBOL/Core


    This is the kernel, the heart of REBOL, with a command-line interface.




    REBOL/View


    This is a graphical client version, an extension of REBOL/Core for
    developers who want to work visually.


    This hack creates a simple Yahoo! Image search widget with the REBOL/ View
    variation. The widget allows you to enter a keyword, display the first
    image in the results, and navigate between other results with Previous and
    Next buttons. This type of graphical user interface (GUI), which uses
    buttons in a familiar desktop-style application, is quite a bit different
    from the scripting, command-line applications in this book.


    To begin, download REBOL/View for your platform at
    http://www.rebol.com/view-platforms.html. Next, you'll need to download a
    modified version of Gavin F. McKenzie's SAX XML parser at
    http://premshree.seacrow.com/code/rebol/xml-parse.r/view. Place
    xml-parse.r in the working directory where you'll create the widget.


    4.11.1. The Code


    Unlike with most GUI frameworks, creating GUIs is a breeze in REBOL.




    In the following commented code, note that comments in REBOL
    begin with a semicolon.






    Save the following code to a file called yahoo.r and be sure to include
    your own Yahoo! application ID:


    REBOL [
    Title: "Yahoo Search Web Services"
    File: %yahoo.r
    Date: 22-May-2005
    Author: "Premshree Pillai"


    Purpose: {
    Yahoo! Search Web services demo
    }
    ]
    ;;
    ; load the SAX XML Parser
    ;;
    do %xml-parse.r


    ;;
    ; set the Application ID
    ;;
    APP_ID: 'insert App ID'


    ;;
    ; This function takes two parameters
    ; 1. query
    ; 2. Application ID
    ; It returns the results as an array of maps
    ; The parsing bit is done by the parse handlers within the parser.
    ;;
    ImageSearch: func [query app_id] [
    return parse-xml+ read rejoin
    [http://api.search.yahoo.com/ImageSearchService/V1/imageSearch '?query='



    query '&appid=' app_id]
    ]


    ;;


    ; Define a layout
    ;;
    out: layout [
    ;;
    ; This will appear as the heading in the widget
    ;;
    H3 400 {
    Yahoo Search Web Services
    demo using REBOL
    }


    ;;
    ; tells REBOL to place following elements across
    ;;
    across
    query: field
    button "Search" [
    ImageSearchResults: ImageSearch query/text 'rebol-yahoo' APP_ID
    curr_count: 1 ; current result no.
    img: load to-url ImageSearchResults/:curr_count/3/2
    backface/image: img
    show backface
    ]


    ;;
    ; tells REBOL to place the following elements below
    ;;
    return


    ;;
    ; A text box
    ;;
    backface: text 400x300 center


    return


    ;;
    ; Navigate to previous search result
    ;;
    button "Previous" [
    curr_count: curr_count - 1
    img: load to-url ImageSearchResults/:curr_count/3/2
    backface/image: img
    show backface


    ]


    ;;
    ; Navigate to next search result
    ;;
    button "Next" [
    curr_count: curr_count + 1
    img: load to-url ImageSearchResults/:curr_count/3/2
    backface/image: img
    show backface


    ]
    pad 0x5
    ]


    ;;
    ; Display the widget!
    ;;
    view out




    This minimal widget has no error handling. However, this code should give
    you a sense of how to use Yahoo!'s Search Web Services with REBOL. Note
    that the work of parsing the XML response is handled by the handlers in
    the SAX XML Parser. Modifications to the parse handler functions are
    commented with my name (Premshree Pillai). If you need to use any of the
    other Yahoo! Search Web Services, you might need to modify the SAX
    handlers.


    4.11.2. Running the Hack


    If you're on Windows, simply double-click the filename and a widget should
    pop up. If you're running Unix, run the hack from the command line, like
    so:


    rebol yahoo.r




    Figure 4-12. A graphical Yahoo! Image search result for "Pink Floyd"




    Figure 4-12. shows the result for a search for Pink Floyd.





    You can click the Next and Previous buttons to browse other Yahoo! Image
    search results.


    Premshree Pillai
















    Chapter 5. Applications















    5.1. Hacks 7791: Introduction


    Basic sample code can get you started with Yahoo! Web Services, but to get
    to know what's available and how you might use the features of the API,
    this chapter shows you some more fully realized applications. They range
    from seriously useful applications (such as Grokker [Hack #77] and
    TagCloud [Hack #88]) that extend Yahoo! features into new directions, to
    the seriously silly (such as Web of Letters [Hack #82] or yReplacer [Hack
    #86]). This chapter intends to give you a taste of what's possible when a
    company like Yahoo! opens its database to outside developers, tinkerers,
    and hackers.


    The hacks in this chapter merely scratch the surface of what's possible,
    and you'll find many more examples of Yahoo! Web Services applications in
    the wild. The best place to spot new applications is at the Yahoo!
    Developer Network application list
    (http://developer.yahoo.net/wiki/index.cgi?ApplicationList). The list is
    open to the public; if you build your own Yahoo! application, be sure to
    add it so others can see what you've builtwhether it increases
    productivity or is a fun distraction.
















    Hack 77. Visualize Yahoo! Web Search Results





    A service called Grokker groups Yahoo! Web Search results into a
    categorized, animated display.


    When you type a query at Yahoo! Web Search (http://search.yahoo.com/),
    Yahoo! will return a list of sites in an order that Yahoo! thinks is best.
    This is a great way to view results when you're looking for a specific bit
    of information, but it's not as helpful if you want to quickly get a broad
    overview of a general topic. A free web service called Grokker
    (http://www.grokker.com/) takes the top 158 Yahoo! Web Search results for
    a query, categorizes the documents in the results, and displays them as
    groups in a visual map.


    Imagine you're looking for information about DNA; type in the term DNA and
    you'll get the familiar sequential list of sites, as shown in Figure 5-1.




    Figure 5-1. Yahoo! Search results for DNA





    You'll find some sites with information about DNA, but it's difficult to
    find patterns within the results. You could mentally categorize sites as
    you browse through the pages of results, but Grokker can do the
    categorization for you, quickly giving you a sense of the type of
    information related to the query DNA. Perform the same query at Grokker,
    and you'll see the radically different display of results shown in Figure
    5-2.


    It takes a few minutes to orient yourself to a Grokker map, but once you
    know how to read the results, you can scan a large amount of information
    fairly quickly.




    Figure 5-2. A Grokker map for DNA





    Each circle on a Grokker map represents a category, and each square
    represents a specific document in the search results. You can click within
    a circle to zoom in on a category and see the documents within. As you can
    see, Grokker grouped results for the query DNA into categories such as
    Basic, Testing, and Molecule. The highlighted Double Helix category is
    within a top-level Structure category. And within the Double Helix
    category are four squares that represent documents that discuss the Double
    Helix structure of a DNA molecule. At a glance, you can see some patterns
    emerging from the search results that you couldn't get from a simple list
    of documents.


    A circle shaded like a sphere on a Grokker map represents a category with
    several results. To see more details within the category, you can click
    the sphere to zoom in. As you zoom in to different parts of the search
    results, you can find more details about the documents in the results.
    Figure 5-3 shows a document detail within the Double Helix category.




    Figure 5-3. Site details on a Grokker map





    As you click to view document details, you'll see a thumbnail preview and
    summary of the document in the right frame. To zoom back to your original
    view of the map, click the Top link at the top of map.


    In addition to the automatic categorization on a Grokker map, you can
    create your own categories within search results. From the main map,
    right-click any empty space and choose Create from the menu. This will
    create a blank circle. Click just below the circle to give your new
    category a title and then start clicking and dragging documents or
    categories into your new category, as shown in Figure 5-4.




    Figure 5-4. A custom category on a Grokker map





    A custom category is a handy way to assemble a handful of documents to
    explore from the hundreds of documents on the original Grokker map.
    Similarly, you can delete any categories from the results by
    right-clicking a circle and choosing Delete from the menu.


    Once you put the time into customizing a Grokker map, you can share it
    with others and save it for yourself by clicking the Email Your Grokker
    Map link at the top of the page. Fill out the form, and Grokker will send
    a link to your custom map to any addresses you specify.




    In the lower-left corner of the map, you'll see a Show Tools
    link. These tools let you search within the map, filter sites
    by date and Yahoo! rank, and adjust the look and feel. You can
    change from a circular map to a square map, or change the
    colors to dark text on a light background.






    Another benefit of using Grokker maps is that you'll find sites deep
    within search results that otherwise you might never have seen. You'd need
    to read through eight pages of Yahoo! Web Search results to see all of the
    documents that make up a single Grokker map. If nothing else, playing with
    this Yahoo! visualization should bring some results to your attention that
    you wouldn't have seen otherwise.


















    Hack 78. Find Links to Any Web Site





    Yahoo! can tell you which sites link to any other site, and yLinkbacks
    uses Yahoo! Search Web Services to find links to the current page you're
    browsing.


    When you browse to a web site you've never seen before, you don't have
    very much advance knowledge about the site. You might know that you've
    followed a link from a particular site that you read frequently, or you
    might have found the site in some search results for a certain search
    term. Of course, the site itself can tell you quite a bit, but that still
    doesn't give you any clues about where the site fits into the larger Web.
    With some searching at Yahoo!, you can get extra info about a site by
    using the special link: syntax.


    If you want to find what sites are linking to any other particular site,
    you can browse to http://search.yahoo.com/ and enter this query:
    link:insert URL. Instead of standard search results, Yahoo! will display a
    list of the sites that link to the URL you've specified in the query. For
    example, if you'd like to find out where the O'Reilly Hacks site fits into
    the Web, you could search for link:http://hacks.oreilly.com/.


    In the results, you immediately get a sense of how many pages link to the
    site and what kinds of sites are linking there. If you're browsing the
    Web, leaving a site to do a quick Yahoo! link: search can be annoying if
    you'd just like to get this sense about the current site you're visiting.
    To find the sites, you need to copy the current URL from your browser
    address bar, open a new window or tab, browse to Yahoo!, and then assemble
    the proper query. It's a quick process, but you can speed it up
    considerably with a bit of classic ASP and a JavaScript bookmarklet.


    This hack uses JavaScript to get the URL of the current page you're
    viewing in your browser. From there, it passes the URL to a server-side
    script that assembles the proper Yahoo! query and fetches the top 10
    results with Yahoo! Search Web Services. A new pop-up window will give a
    quick look at which sites are linking to the current page, without leaving
    your place.


    5.3.1. The Code


    The first part of this hack is a server-side script that retrieves the
    search results and formats them for display. The HTML result will end up
    being inserted into a separate pop-up browser window above the current
    page.


    The script accepts a URL with the querystring variable q. From there, it
    creates a Yahoo! Search Web Services URL using the special link: syntax.


    To create the script, save the following code to a file called yl.asp and
    be sure to include your own unique application ID in the code:





    Yahoo Linkbacks






    <%


    On Error Resume Next
    Response.Buffer = True
    '' Expecting a URL string to be in the querystring "q"
    szQ = Request("q")
    If (szQ <> "") Then %>






    style='font-weight:bold;text-align:center;width:98%;padding-top:20px;'>
    Loading…

    <% Response.Flush %>





      <%Dim objXML, xml
      szStr = ""
      szUrl = ""
      szTitle = ""


      szSummary = ""
      set xml = Server.CreateObject ("MSXML2.ServerXMLHTTP.3.0")


      szGetString = ("http://api.search.yahoo.com/" &_
      "WebSearchService/V1/webSearch?" &_
      "appid=[YOUR_APPLICATION_ID ]&results=10&query=link :" & szQ)


      xml.Open "GET", szGetString, False
      xml.Send
      set objXML = xml.responseXML


      If (objXML.getElementsByTagName("Result").length>0) Then
      If (objXML.getElementsByTagName("Result").length>10) Then
      nLen = 10
      Else


      nLen = objXML.getElementsByTagName("Result").length-1
      End if
      For z = 0 to nLen


      '' Get each "Result" Node and loop through
      '' its childNodes to get Url, Title and Summaries
      Set nGb = objXML.getElementsByTagName("Result")(z)
      set o18 = nGb.childNodes
      For k = 0 to o18.length-1
      Select Case (o18.item(k).nodeName)
      Case "Title"
      szTitle = o18.item(k).text
      Case "Summary"
      szSummary = o18.item(k).text
      Case "Url"
      szUrl = o18.item(k).text
      End Select
      Next


      If (szSummary <> "") Then szSummary = ": " & szSummary


      szStr = szStr & ("
    • " & szTitle &



      "
      ")
      szStr = szStr & (szSummary & "
    • ")


      szUrl = ""
      szTitle = ""
      szSummary = ""


      Next
      End if
      If (szStr <> "") Then
      Response.write(szStr)
      Else
      Response.write("
    • No Results Found
    • ")
      End if


      set xml = Nothing
      set objXML = Nothing
      End if %>










    Upload yl.asp to a public web server to make it available to the
    bookmarklet. The bookmarklet is a bit of JavaScript that resides in a
    bookmark and calls the ASP page in-context by sending the URL of the page
    currently in the browser.


    5.3.2. Running the Hack


    Add the following code to an existing bookmarklet by adding it to the
    location field. Be sure to include the URL of the server-side page,
    yl.asp:


    javascript:function p(){window.open(('http://example.com/yl. asp?q='+



    document.location. href),'nsm','width=250,height=350,directories=no,



    location=no,menubar=no, scrollbars=yes,status=no,toolbar=no,



    resizable=no,left=0,top=0,screenx=0,screeny=0')}p()




    Name the bookmarklet yLinkback, and you should be set for easy access to
    linking information. For example, if you browse to the photo-sharing web
    site Flickr (http://www.flickr.com/) and click the yLinkback bookmark,
    you'll see a pop-up window like the one shown in Figure 5-5.




    Figure 5-5. The yLinkbacks pop-up window at Flickr





    A quick survey of the sites there shows that Flickr is linked by many
    personal weblogs, and this can let you know that the site is probably a
    favorite with the weblog community. Once you have the yLinkbacks
    bookmarklet installed, you can gather some quick information like this for
    any web site you visit. If you'd rather not build your own version of the
    hack, you can install the bookmarklet at
    http://www.kokogiak.com/yahoo_linkbacks.html.


    Alan Taylor















    Hack 79. Import Yahoo! Local Listings into Your Address Book





    A freely available program called gvcard can help you import a Yahoo!
    Local listing into your email address book, cell phone, or any application
    that understands vCard.


    Have you ever wondered why it is so darn hard to import search results
    from Yellow Pages sites like Yahoo! Local (http://local.yahoo.com/) into
    other programs? Whether you are at your desk or using your fancy Treo 650,
    wouldn't it be nice if you could import these addresses, phone numbers,
    and URLs directly into your address book? Now you can.


    gvcard (http://gvcard.sf.net/) is a free program that wraps common Yellow
    Pages services from Yahoo! and Google and makes their results available in
    the vCard format. gvcard is written in Python and the source code is
    available via CVS.


    gvcard comes in four flavors (all four versions are available at the
    gvcard web site):



    A standalone CGI script that you can run from any web site



    A command-line client you can run locally just about anywhere



    A weblet version of the CGI script that you can also run locally



    A plug in for IMSmarter.com (http://imsmarter.com/developer.php) that
    allows you to access gvcard over IM


    At the heart of gvcard is the vCard standard: a simple text-based format
    that almost all phone book, address book, and calendaring applications
    understand. vCard allows these programs to share contact information
    across a wide variety of platforms. By wiring vCard up to Yahoo! Local,
    gvcard helps you avoid searching for the same information twice. Best of
    all, it makes local business information easy to take with you on all
    kinds of portable devices, from PDAs to cell phoneseven those without
    Internet access.


    You can view the complete vCard standard at http://www.imc.org/pdi, but
    it's easy to see how it works in an example:


    BEGIN: VCARD
    FN:Coupa Cafe
    ORG:Coupa Cafe
    ADR;DOM;POSTAL;WORK:538 Ramona St;;;Palo Alto;CA;;
    TEL;Work;VOICE;PREF:(650) 322-6872
    URL:http://www.coupacafe.com/
    UID:http://www.coupacafe.com/
    NOTE:***Directions: http://xrl.us/fbu5 ***Search: http://xrl.us/fbu4
    VERSION:2.1
    END: VCARD




    Every line in the vCard has a tag and value, such as ORG:Coupa Cafe, which
    identifies this vCard as being for the organization Coupa Cafe. It also
    has additional bits of metadata that work similarly to XML's attributes,
    such as PREF, which indicates that the work phone number listed is the
    preferred mode of contact. Unfortunately, the vCard standard predates the
    widespread adoption of XML as the Web's "one true metadata format," so
    some of its features are a bit archaic. Thankfully, we don't have much
    need for its advanced features.




    If you're interested in playing around with vCards, the
    following handy site has a simple CGI that will generate them
    from an HTML form: http://www.vcardprocessor.com/try.htm.






    Accessing Yahoo! Local is a snap, thanks to Yahoo!'s excellent web
    services support. Like all Yahoo! APIs, Yahoo! Local works via REST, a
    simple technique whereby a client makes a standard HTTP request using GET
    parameters and receives an XML response. The client applicationin this
    case, gvcardneeds to be able to correctly format the request based on user
    input and then parse and present the response. Here's a sample Yahoo!
    Local query:


    http://api.local.yahoo.com/LocalSearchService/V1/localSearch?appid=insert



    App ID&query=pizza&zip=94306&results=2




    And here's an excerpt of the response it generates:





    totalResultsReturned="2" firstResultPosition="1">




    http://local.yahoo.com/mapview?stx=pizza&csz=Palo+Alto%2C+CA&city=



    Palo+Alto&state=CA&radius=5&ed=BVD56a131DxIV6V7_5O_wO8KQY1.bxtOAd8qew--







    Round Table Pizza Palo Alto
    3407 Alma St

    Palo Alto
    CA
    (650) 494-2928



    0.28




    http://local.yahoo.com/details?id=21395990&state=CA&stx=pizza&csz=Palo+Alto



    +CA&ed=o9pJ_q160Sy74qzFN72I0cSInA8HkgnO3mChobdW6IFvjLcw9Npqo0NC0IKIFIrT








    http://local.yahoo.com/details?id=21395990&state=CA&stx=pizza&csz=Palo+



    Alto+CA&ed=o9pJ_q160Sy74qzFN72I0cSInA8HkgnO3mChobdW6IFvjLcw9Npqo0NC0IKIFIrT










    http://maps.yahoo.com/maps_result?name=Round+Table+Pizza+Palo+Alto&desc=



    6504942928&csz=Palo+Alto+CA&qty=9&cs=9&ed=o9pJ_q160Sy74qzFN72I0cSInA8H



    kgnO3mChobdW6IFvjLcw9Npqo0NC0IKIFIrT




    http://www.roundtablepizza.com/


    http://www.roundtablepizza.com/






    Most of the elements in this XML are straightforward and map pretty
    closely to the corresponding fields in the vCard. Because some of the URLs
    are lengthy, gvcard often uses a URL rewriting service from
    http://www.metamark.net/ to keep the URL lengths manageable. Other than
    that, the data is copied directly from Yahoo! Local XML responses to the
    vCard.


    5.4.1. The Code


    Although gvcard comes in several varieties, each with its own user
    interface, they all work according to the following basic four-step
    procedure:



    Get input, consisting of a search term (such as pizza in our previous
    example) and a location (such as 94301 or "Palo Alto, CA").



    Pass the request to Yahoo! Local and parse the response.



    Create a vCard using the appropriate fields.



    Present the result for easy import into an address book application.


    gvcard is written in Python, and even if you're not familiar with Python,
    the following code example should be straightforward.


    At the heart of all gvcard versions is the lookup.py module. Its job is to
    formulate the request and parse the response. This is accomplished with
    two simple classes, YahooLocalRequest and YahooParser:


    class YahooLocalRequest:
    def __init__(self, searchTerm, location):
    self.baseUrl_ = "http://api.local.yahoo.com/LocalSearchService/V1/



    localSearch"
    self.params_ = {"appid":"gvcard-python",
    "query": searchTerm,
    "location": location
    }


    self.url_ = "%s?%s" % (self.baseUrl_, urllib.urlencode(self.params_))
    self.request_ = urllib2.Request(url=self.url_)


    def fetchRaw(self):
    f = urllib2.urlopen(self.request_)
    self.contents_ = f.read()
    return self.contents_






    gvcard also works with Google Local, which is a nearly
    equivalent service. However, Google does not provide a web
    services API for its Local search, and the code to interface
    with it is much more complicated. Feel free to compare the two
    if you ever need to make the case for web services to
    somebody.






    If you're familiar with python's urllib2 module, this code will look
    completely familiar. Take the search term and location (along with an
    appid, which is assigned by Yahoo!), URL-encode them, and retrieve the raw
    XML as text via HTTP. The YahooParser does the rest (no pun intended):


    class YahooParser:
    def __init__(self):
    self.results_ = {}


    def get(self, xml, tag, default=""):
    rs = xml.getElementsByTagName(tag)
    if not rs:
    return default
    element = rs[0]
    textNode = element.firstChild
    if textNode:
    return textNode.data
    else:
    return default


    def feed(self, data):
    dom = xml.dom.minidom.parseString(data)
    rs = dom.getElementsByTagName("ResultSet")[0]
    for i, result in enumerate(rs.getElementsByTagName("Result")):
    self.results_[i] = { "phone" : self. get(result, "Phone"),
    "directionsUrl" : self.get(result,



    "MapUrl"),
    "homepageUrl" : self.get(result,



    "BusinessUrl"),
    "city" : self.get(result, "City"),
    "state" : self.get(result, "State"),
    "zip" : "",
    "street" : self.get(result, "Address"),
    "name" : self.get(result, "Title"),
    "searchUrl" : self.get(result, "ClickUrl")
    }
    return self.results_




    The feed() method constructs a Python dictionary that holds the relevant
    data for each result. Use the get() method as a simple wrapper for
    python's xml.minidom module, whose API is not entirely well suited to the
    kind of parsing we're doing here.


    Finally, the results of the search are passed to the makevcard module,
    which looks like this:


    def generateVCard(name, street, city, state, zip, phone, url=None,
    location=None, note=None, searchUrl=None):
    text = ""
    text += "BEGIN:VCARD\n"
    text += "FN:%s\n" % name
    text += "ORG:%s\n" % name
    text += "ADR"
    text += ";DOM;POSTAL;WORK:"
    text += "%s;" % street
    text += ";;%s;%s;%s;\n" % (city, state, zip)
    text += "TEL;Work"
    text += ";VOICE"
    text += ";PREF"
    text += ":%s\n" % phone
    if url:
    text += "URL:%s\n" % url
    text += "UID:%s\n" % url


    if not note:
    note = ""
    if searchUrl:
    note += " ***Search: %s" % searchUrl
    if note:
    text += "NOTE:***Directions: %s\n" % note
    text += "VERSION:2.1\n"
    text += "END:VCARD\n"
    return text




    The vCard is then presented to the user in a form that is easy to import.
    Because the CGI version of gvcard is the most widely used, let's take a
    look at its inner workings:


    form = cgi.FieldStorage()
    try:
    location = form["location"].value
    except KeyError:
    if recentLocations:
    location = recentLocations[0]
    else:
    location = ""
    try:
    search = form["search"].value
    except KeyError:
    search = ""




    As you can see, this code handles the input from the web form and verifies
    that the user has entered information.


    5.4.2. Running the Hack


    To pull it all together into a script, start by using Python's built-in
    cgi module to get the query parameters. Next, the program emits the actual
    HTML that the user will see:


    cprint( "" )
    cprint( " Local Google -> vCard: %s" % mode )
    cprint( "
    Business name:
    " %



    search )
    cprint( "Location: (e.g. Palo Alto,



    CA or 94301)
    " % location )
    cprint( "Choose a local search provier:
    ")
    cprint( " Show at most" )
    cprint( "
    results
    " )




    If you've been provided with search terms, go ahead and run the search,
    using the lookup module:


    if search and location:
    if location in recentLocations:
    recentLocations.remove(location)
    recentLocations.insert(0, location)
    tpl = (search, location)
    if tpl in recentSearches:
    recentSearches.remove(tpl)
    recentSearches.insert(0, tpl)


    results, url = lookup.resultsForQuery(searchTerm=search,



    location=location, searchType=searchType)
    cprint( "Results (from these raw search



    results
    ):

    " % url)




    Next, present a list of all the results, in a simple, stripped-down HTML
    format. This HTML page renders equally well on most cell phone and PDA web
    browsers, allowing access to gvcard from a wide variety of devices:


    for valueDict, vc in results[:maxResults]:
    for entry in ResultTemplate.split("\n"):
    oe = entry
    for k, v in valueDict.items():


    entry = entry.replace("$%s" % k, v)
    if oe != entry:
    cprint( entry )
    qs = urllib.urlencode(valueDict)
    cprint( " vCard: download here




    "% qs )
    cprint( "


    " )




    One technique to note here is the use of a simple template to present each
    result. The template (called ResultTemplate in the preceding code
    fragment) looks like this:


    ResultTemplate = """
    $name

    $street

    $city, $state $zip

    $phone

    $homepageUrl

    $searchType Link -
    Directions


    """




    This template could easily be changed to something more graphically rich,
    perhaps incorporating some additional elements of Yahoo! Local (such as
    its mapping features) that are not currently supported by gvcard.


    The last aspect of gvcard for which the CGI script is responsible is to
    provide the user a way to easily import the vCard into her address book
    program of choice. Since gvcard is designed to work with the widest
    possible array of programs and platforms, this is a bit tricky. Notice the
    line from the previous fragment that looked like this:


    cprint( "vCard: download here
    "



    % qs )




    This constructs a link to another part of gvcard, the vcardcgi.cgi script.
    It's responsible for emitting the vCard data itself, using the correct
    MIME type: text/x-vcard. Keep in mind that not all browsers recognize the
    vCard MIME type, but most know about the vCard file extension .vcf, which
    is why the link is written with the trailing /card.vcf. Many browsers will
    assume this is the filename of the file being downloaded and invoke the
    right program to handle it.


    A freely accessible running instance of the gvcard CGI script is available
    at http://www.speakeasy.org/~ericries/gvcard/lookupcgi.cgi, so feel free
    to try it out. Bookmark this URL in your phone, PDA, or handheld's web
    browser and surprise yourself with how many times it comes in handy. At
    the very least, you'll save yourself a few bucks in calls to 411.


    Eric Ries
















    Hack 80. Create a Yahoo! Local MIDlet





    Use Java for mobile devices to access the Yahoo! Local API on a mobile
    device.


    The Yahoo! Local Search service allows you to search the Internet for
    businesses near a specified location. With the availability of a REST web
    service interface to Yahoo! Local Search, it is quite simple to implement
    an application that enables mobile devices to access Yahoo! Local Search.
    It might save you the cost of expensive 411 calls to find out the phone
    number or the address of a business when you are traveling.


    Before you build the hack, it might help to familiarize yourself with a
    couple of important terms you'll encounter:




    MIDlet


    A MIDlet is a Java application for small devices like cell phones. More
    specifically, it's a Java 2, Micro Edition ( J2ME™) application that is
    conformant with the Mobile Information Device Profile ( MIDP)
    specification.




    J2ME


    J2ME is a group of Java APIs for creating applications on small devices
    like cell phones, pagers, PDAs, and set-top boxes.


    This hack shows you how to build a MIDlet that allows users to perform
    local search, implemented over Yahoo! Local Search API, from a mobile
    device.


    5.5.1. What You Need


    To use this hack, you'll need a Handspring Treo 600 running the Web-Sphere
    Everyplace Micro Environment (WEME), which you'll find at
    http://www.palmone.com/us/support/jvm.


    You'll also need the Sun Java Wireless Toolkit Version 2.2, which you can
    find at http://java.sun.com/products/j2mewtoolkit, and the Eclipse
    development environment with the EclipseME plug-in for building MIDlets,
    available at http://eclipseme.org/.


    5.5.2. The Code


    The code for this hack is organized into three files:




    LocalSearch.java


    MIDlet described in more detail below




    LocalSearchResponseHandler.java


    SAX event handler class used to parse the response from Yahoo! Local
    Search




    URLUTF8Encoder.java


    Utility class used to encode special characters in the URL




    You can download the complete code for this hack at
    http://mobile-j2me.blogspot.com/.






    The code in LocalSearch.java handles most of the work. This file
    implements the MIDlet interface requirements, describes the application
    interface, and handles any user interaction. Here's a look at the key
    methods in LocalSearch.java:


    // package/import statements
    public class LocalSearch extends MIDlet implements CommandListener
    {
    // Data members
    public LocalSearch()
    {
    // Create the UI forms and the buttons/commands
    }
    protected void startApp() throws MIDletStateChangeException
    {
    // Set the display to the main form
    }
    protected void pauseApp()
    {
    // Not used
    }
    protected void destroyApp(boolean unconditional)
    {
    // Not used
    }
    public void commandAction(Command c, Displayable s)
    {
    // Handle commands from the UI
    // Retrieve data entered by the user
    // Invoke Yahoo! Local Search (see doYahooLocalSearch())
    // Parse the response
    // Display the results or error to the user
    }
    // Invoke Yahoo Local Search and get response
    private String doYahooLocalSearch() throws IOException
    {
    // Invoke Yahoo Local Search
    String url =
    "http://api.local.yahoo.com/LocalSearchService/V1/localSearch?"
    + "appid="
    + appID
    + "&query="
    + URLUTF8Encoder.encode(query)
    + "&results="
    + results
    + "&start="
    + start
    + "&zip=" + zip;


    return(postViaHttpConnection(url).toFormattedString());
    }
    private LocalSearchResponseHandler postViaHttpConnection(String url)



    throws IOException
    {
    // POST a HTTP request with the URL
    // Retrieve the response (XML document)
    // Invoke parseXML()
    }
    // Parse the response XML document using SAX and retrieve
    // the needed information
    private LocalSearchResponseHandler parseXML(InputStream is) throws



    SAXException, IOException
    {
    }
    }




    The following code is a SAX handler that retrieves the title, phone
    number, and address from each of the businesses that Yahoo! returns. Here
    are the key methods in LocalSearchResponseHandler.java:


    // package/import statements
    class LocalSearchResponseHandler extends DefaultHandler
    {
    // Data members


    public void startElement(String uri, String localName, String qName,



    Attributes attributes) throws SAXException
    {
    // Keep track of QNames
    qNameStack.push(qName);


    // Get the # of results available and the # of results
    // returned in the response
    if (qName.equals(ELEM_RS))
    {
    totalResultsAvailable=attributes.getValue(ATTR_TRA);
    totalResultsReturned = attributes.getValue(ATTR_TRR);
    }


    currentElementContent = "";
    }


    public void characters(char[] ch, int start, int length)
    throws SAXException
    {
    currentElementContent = currentElementContent + new String(ch, start,



    length);
    }


    public void endElement(String uri, String localName, String qName)
    throws SAXException
    {
    // Get current QName
    qName = (String) qNameStack.peek();


    // Get the title, phone, address of the listing
    if (ELEM_TITLE.equals(qName))
    {
    titles.addElement(currentElementContent);
    }
    else if (ELEM_PHONE.equals(qName))
    {
    phones.addElement(currentElementContent);
    }
    else if (ELEM_ADDRESS.equals(qName))
    {
    addresses.addElement(currentElementContent);
    }


    // Pop QName, since we are done with it
    qNameStack.pop();
    }


    }




    5.5.3. Running the Hack


    Once you have the source files in place, you can build the application
    from within Eclipse by right-clicking the project and selecting Build
    Project. Or to package the application, right-click the project and select
    J2ME Create Package.


    Upload the resulting YahooWebServices.jar file to a publicly accessible
    web server. Then use the IBM MIDlet manager on the Treo to download the
    MIDlet at the appropriate URL.


    Once the code is installed, launch the IBM MIDlet manager from the
    handheld. You should see a screen similar to that shown in Figure 5-6.




    Figure 5-6. MIDlet manager







    You can also use the MIDlet manager to install a different
    MIDlet or get a new version of the Yahoo! Web Services MIDlet.






    From the manager, select the Yahoo Web Services MIDlet and click Launch.
    The main screen of the MIDlet will appear, as shown in Figure 5-7.




    Figure 5-7. MIDlet entry form





    There are five fields you can fill in on the form. AppID identifies the
    user of Yahoo! Local Web Services. By default, its value is set to
    YahooDemo, but you can get your own app ID at
    http://api.search.yahoo.com/webservices/register_application. The Query
    field is for the business you're looking for; Results is for the number of
    results that you want to see on the results screen; and Start identifies
    the point from where you would like to see the results from the complete
    list. Finally, ZIP is for the Zip Code that identifies the location where
    you want to do the search.


    Enter the name of a local business or type of business along with your Zip
    Code and click Search. You should see results like those shown in Figure
    5-8.




    Figure 5-8. MIDlet results





    If the top results aren't quite what you're looking for, you can click
    Next to see more.


    Assembling this hack takes a bit of work, but it's an excellent example of
    seamlessly integrating Yahoo! data into unusual places, such as
    applications for mobile devices.


    Deepak Nadig















    Hack 81. Import Yahoo! Local Listings into Excel





    Bringing Yahoo! Local Search results into a spreadsheet can help you sort,
    view, and visualize local businesses.


    Having access to the Yahoo! Local API is like being able to effortlessly
    move entries from the physical Yellow Pages to your computer. And dumping
    the entries into a structured environment like Excel can give you a new
    way to look at Yahoo! Local Search results.


    Imagine that you find yourself in Corvallis, Oregon, and you'd like to
    find a spot to sit down, grab a bite to eat, and surf the Internet
    wirelessly. A Yahoo! Local Search for wifi near the Corvallis Zip Code
    (97333) will turn up several results for businesses that have wireless
    Internet access, as shown in Figure 5-9.




    Figure 5-9. Yahoo! Local Search for "wifi" near 97333





    Unfortunately, Yahoo! Local won't tell you which places have free wireless
    access, so you'd have to call each of the businesses to ask them. You
    could scroll and click through the web page and jot down each phone
    number, or you could take advantage of the Yahoo! Local API to import the
    list into a spreadsheet for quick reference to the phone numbers.


    5.6.1. Exporting Yahoo! Local Search to a Spreadsheet


    Programmer Rikul Patel has already done much of the work involved with
    importing results into a spreadsheet. His program, called Yahoo! Local
    Search To Excel, is available for free at
    http://rikulpatel.com/ylocalsearch.php. It's available on Windows only,
    and you'll need a spreadsheet program such as Excel to view the results.


    Once you download the program, there's nothing to install. Double-click
    YLocalSearch.exe and you'll see a form like the one shown in Figure 5-10.




    Figure 5-10. The Yahoo! Local Search To Excel form





    Type in a query, Zip Code, and radius, and then click Local Search. Behind
    the scenes, the program asks Yahoo! for the data and formats the response
    as a comma-separated value ( CSV) file. The program will ask you to name
    the file, so call it something appropriate, like corvallis_wifi.csv in
    this example. If Excel is installed on your system, corvallis_wifi.csv
    should open in Excel when you double-click it, and you'll see a
    spreadsheet like the one shown in Figure 5-11.




    Figure 5-11. Yahoo! Local results in an Excel spreadsheet





    The spreadsheet includes the name, address, city, state, and phone number
    of the business. If Yahoo! has a web site listed for the business, that's
    included as well. With the data in the spreadsheet, you can then add your
    own columns, mix it with existing data, or even create charts based on the
    data. And this definitely makes for a quick list of phone numbers you can
    call to see who has free wireless in the area.


    5.6.2. Using Perl


    Yahoo! Local Search To Excel is easy to use, but the output isn't very
    flexible. To access some of the other data available through the Yahoo!
    APIsuch as distance and user ratingsyou'll need to write your own code.
    Luckily, this is fairly quick work with a scripting language like Perl.


    5.6.2.1. The code.


    Much like the previous program, this Perl script accepts a query and a Zip
    Code and assembles a CSV file with results from a Yahoo! Local Search. As
    with most of the other Perl examples in this book, you'll need to have
    LWP::Simple and XML::Simple installed on your system for requesting and
    parsing Yahoo! data. You'll also need the Getopt::Simple module for
    handling the command-line parameters. Save the following code to a file
    called yahoo_excel.pl:


    #!/usr/bin/perl
    # yahoo_excel.pl
    # Accepts a query and zip code and returns a CSV
    # list of results you can open in Excel.
    # Usage: yahoo_excel.pl -q -z
    #
    # You can create an AppID, and read the full documentation
    # for Yahoo! Web Services at http://developer.yahoo.net/


    use strict;
    use Getopt::Simple qw($switch);
    use LWP::Simple;
    use XML::Simple;


    # Set your unique Yahoo! Application ID
    my $appID = "insert app ID";


    # Get/Set the command line options
    my $options =
    {


    q =>
    {
    type => '=s',
    env => '-',
    default => '',
    verbose => 'Specify a query',
    order => 1,
    },
    zip =>
    {
    type => '=f',
    env => '-',
    default => '',
    verbose => 'Specify a zip code',
    order => 2,
    },
    };
    my $option = Getopt::Simple->new();
    if (!$option->getOptions($options,
    "Usage: yahoo_excel.pl -q [query] -z [zip code]")) {
    exit(-1);
    }


    # Make sure the command line options have values
    my $query = $$switch{'q'};
    my $zip = $$switch{'zip'};
    if ((!$query) || (!$zip)) {
    print "Usage: yahoo_excel.pl -q -z ";
    exit;
    };


    # Construct a Yahoo! Local Query with only required options
    my $language = "en";


    my $req_url = "http://api.local.yahoo.com/";
    $req_url .= "LocalSearchService/V1/localSearch?";
    $req_url .= "appid=$appID";
    $req_url .= "&query=$query";
    $req_url .= "&zip=$zip";


    # Make the request
    my $yahoo_response = get($req_url);


    # Parse the XML
    my $xmlsimple = XML::Simple->new();
    my $yahoo_xml = $xmlsimple->XMLin($yahoo_response);


    # Loop through the items returned, printing as CSV
    print "\"Title\",\"Address\",\"Distance\",\"Rating\"\n";
    foreach my $result (@{$yahoo_xml->{Result}}) {
    my $title = $result->{Title};
    my $address = $result->{Address};
    my $distance = $result->{Distance};
    my $rating = $result->{Rating};
    if (!eval($rating)) {
    $rating = "";
    }
    print "\"$title\",\"$address\",\"$distance\"\,\"$rating\"\n";
    }




    With a bit more control over the file, you can decide which columns you'd
    like to include in your spreadsheet. As you can see in the last line of
    this code, the script prints the title of the business, the address, the
    distance from the center of the Zip Code, and the rating as an average of
    Yahoo! user ratings for that business.


    5.6.2.2. Running the hack.


    Run the code from the command line by passing in the two parameters: -q
    followed by a query, and -z followed by a Zip Code. If you're still
    looking for wireless hotspots in Corvallis, you might call the script like
    this:


    perl yahoo_excel.plq wifiz 97333




    If all goes well, you should see a block of text scroll past with all of
    the options. Because you'd rather read the results in a spreadsheet, you
    should pipe the results to a CSV file, like so:


    perl yahoo_excel.plq wifiz 97333 > wifi.csv




    Double-click the newly created wifi.csv to see the results of the query,
    and you should have something like what's shown in Figure 5-12.




    Figure 5-12. Custom Yahoo! Local results in an Excel spreadsheet





    With a custom script, you can now quickly see not only which businesses
    offer wireless Internet access, but also how close they are and how Yahoo!
    users have rated each business. The key to the hack is that, thanks to
    Yahoo!'s open API, you can add the search results to other programs such
    as Excel and structure the data in ways that are useful to you.















    Hack 82. Spell Words with Yahoo! Images





    Web of Letters combines Yahoo! Image Search results to spell a single
    word.


    The Web of Letters is a PHP script that uses the Yahoo! Image Search API
    to grab images of letters from all over the Web to spell words. The
    resultsa combination of photos and illustrationsare always surprising and
    can even look like modern art. You simply type a word into a web form, and
    the script assembles the images.


    The key to the hack is transforming the user's word into the proper Yahoo!
    query. When the user enters hello, the code queries Yahoo! Image Search
    for each letter in the word"letter h", "letter e", "letter l", and so
    oneventually spelling the complete word, as shown in Figure 5-13.




    Figure 5-13. The word "hello" assembled from Yahoo! Images





    When the character is a number, the query syntax is "number 1", "number
    2", etc. When the character is a symbol, the code queries Yahoo! for its
    full name; the symbol & becomes ampersand.


    You can try a working Web of Letters is at
    http://blog.outer-court.com/yahoo/letters.php5.


    5.7.1. The Code


    Web of Letters uses PHP5, and you can start by creating a file called
    letters.php5. In addition to a standard HTML head, add the following code
    to accept a query parameter q:


    $q = ( isset($_POST['q']) ) ? $_POST['q'] : '';




    Then add the following XHTML snippet, which will ask the user for input:



    Enter anything:
    value="" />






    Print the query in the input box if something has been posted already, but
    make sure to convert it to an HTML attribute value using the toAttribute
    function:


    function toAttribute($s)
    {
    $s = toXml($s);
    $s = str_replace('"', '&"', $s);
    return $s;
    }


    function toXml($s)
    {
    $s = str_replace('&', '&', $s);
    $s = str_replace('<', '<', $s);
    $s = str_replace('>', '>', $s);
    return $s;
    }




    The heart of the code shows the images retrieved from Yahoo!.




    The script accepts only words of up to 40 letters. It's also
    wise to implement a cache when you query Yahoo!; "letter b"
    will be used for every b, but we do not need to query Yahoo
    every time for this.








    if ($q != '')
    {
    ?>

    Spelling

    (reload for variations):



    if ( strlen($q) <= 40 )
    {
    for ($i = 0; $i < strlen($q); $i++)
    {


    $letter = substr($q, $i, 1);
    switch ( strtolower($letter) )
    {


    case '.':
    showImage('dot');
    break;


    case '_':
    showImage('underscore');
    break;


    case '-':
    showImage('minus');
    break;


    case '/':
    showImage('slash');
    break;


    case ':':
    showImage('colon sign');
    break;


    case '$':
    showImage('dollar');
    break;


    case '0':
    case '1':
    case '2':
    case '3':
    case '4':
    case '5':
    case '6':
    case '7':
    case '8':
    case '9':
    showImage('"number ' . $letter . '"');
    break;


    case '!':
    showImage('"exclamation mark"');
    break;
    case '?':
    showImage('"question mark"');
    break;
    case 'a':
    case 'b':
    case 'c':
    case 'd':
    case 'e':
    case 'f':
    case 'g':
    case 'h':
    case 'i':
    case 'j':
    case 'k':
    case 'l':
    case 'm':
    case 'n':
    case 'o':
    case 'p':
    case 'q':
    case 'r':
    case 's':
    case 't':
    case 'u':
    case 'v':
    case 'w':
    case 'x':
    case 'y':
    case 'z':
    showImage('"letter ' . $letter . '"');
    break;


    default:
    echo '
    ';
    break;
    }
    }
    }
    else
    {
    echo '

    Up to 40 letters only.

    ';
    }
    }




    The switch-case clause calls the showImage function that grabs 20 images
    from Yahoo! for every query and then displays one at random:


    function showImage($q)
    {
    $max = 20;
    $s = '';
    $url = 'http://api.search.yahoo.com/ImageSearchService/' .
    'V1/imageSearch?appid=insert app ID&'.
    'query=' . urlencode($q) .
    '&results=' . $max;


    $dom = new domdocument;
    $dom->load($url);


    $xpath = new domxpath($dom);
    $i = rand(0, $max - 1);
    $source = $xpath->query('//Result/Thumbnail/Url')->
    item($i)->firstChild->data;
    echo ' 'style="width:80px; height:80px" alt="" />';
    }




    5.7.2. Running the Hack


    Upload letters.php5 to your server and view it with your browser. Type a
    word in the form and click Display. You should see a group of letters
    spelling your word, like the results for Yahoo! Hacks shown in Figure
    5-14.




    Figure 5-14. "Yahoo! Hacks" spelled by the Web of Letters





    As you can see in Figure 5-14, all images are scaled to 80 pixels by 80
    pixels, so they have the same size. The script uses inline styles, but you
    might want to move the style definitions into a separate CSS stylesheet to
    keep the HTML lean.


    With Web of Letters, you can use the power of images across the Web for
    some fun. Happy writingand no ransom notes, please!


    Philipp Lenssen


















    Hack 83. Randomize Your Windows Desktop Background





    Use the Yahoo! Image Search web service to spin a virtual roulette wheel
    and let fate choose your desktop background image.


    People love to change their desktop backgrounds. It's one of the first
    skills that new computer users learn, and even old computer pros fiddle
    with their desktop background image on a fairly regular basis. Browsing
    through the aisles of your local computer shop, you'll find CDs full of
    scenic imagery that you can use as your desktop background pictures. But
    why shell out money for custom backgrounds, when you can use the entire
    Web as your source for background images?


    The Yahoo! Image Search is a good place to start your search for a new
    desktop background. Point your browser to http://search.yahoo.com/images
    and type in a query, such as landscape. You should find many thumbnails of
    images, such as the ones in Figure 5-15, which would make suitable desktop
    backgrounds.




    Figure 5-15. Yahoo! Image Search results for "landscape"





    Underneath each photo is the name of the image file, its size in pixels,
    and the URL where the image was found. The closer the image is to the size
    of your current desktop, the better it will look as a background. To find
    out your desktop's current resolution, right-click anywhere on your
    desktop, choose Properties from the menu, and click the Settings tab. The
    current size of your desktop is listed under Screen Resolution and is
    typically 800 pixels wide by 600 pixels tall, or a bit larger at 1024 x
    768. As monitors have been getting bigger, desktop sizes have been
    increasing as well.


    To find the best images to use as backgrounds, perform an advanced image
    search (http://search.yahoo.com/images/advanced) and set the Size option
    to "large" or "wallpaper." This will exclude any images that wouldn't make
    good desktop backgrounds, such as buttons or icons. You can also include
    some search meta keywords with your query to find images with a specific
    size. For example, if your desktop is 1024 x 768, you could use the query
    landscape width:1024 height:768 to find only images that match your
    desktop resolution. The width and height keywords tell Yahoo! Image Search
    to return only images with the specified size.


    From the search results, click on an image that's close to your desktop
    size to see the page on which Yahoo! found the original image. From the
    top frame, click the View Image link to display the original image by
    itself in your browser window. Right-click anywhere on the image and
    choose "Set as Wallpaper" in Firefox or "Set as Background" in Internet
    Explorer. Then you can close your browser and see your new background
    image!


    This process is easy to follow anytime you're ready for a new background,
    but with a little scripting, you can speed things up and let chance decide
    which picture you should use.


    5.8.1. The Code


    This hack contacts Yahoo! via its Web Services API, performs an image
    search, chooses one of the responses at random, downloads the image, and
    sets it as your desktop background. Because Windows expects desktop
    backgrounds to be the bitmap image type and most web images are JPEGs, the
    script will also have to convert any image from a JPEG to a bitmap.


    This conversion process is out of the scope of the Windows scripting
    environment, and this hack uses a third-party ActiveX component that
    converts JPEG files to bitmaps. An ActiveX component is a piece of
    software that is meant to be used by other programs, and it usually
    performs a specific task. Alex K. Angelopoulos wrote this particular
    component, called Convert to Bitmap, and published it on his web site. You
    can download a copy at
    http://dev.remotenetworktechnology.com/wsh/comwsh.htm. Once you've
    downloaded the file and unzipped the contents, you'll need to install the
    component so it's available to scripts. From a command line, browse to the
    directory where you unzipped the package and type the following command:


    Regsvr32 GfxConverter.ocx




    With the component installed, you'll be set to run the script. Save the
    following code to a file called Y!background.vbs:


    '----------------------------------------------------
    ' Y!Background.vbs
    '
    ' Finds a random image via the Yahoo! Image API and
    ' sets it as the desktop background image.
    '
    ' This script depends on GfxConverter.ocx that you
    ' download here:
    '
    ' http://dev.remotenetworktechnology.com/wsh/comwsh.htm
    '
    ' Click/Save "Convert to Bitmap", unzip, and install
    ' from the command line, like this:
    '
    ' Regsvr32 GfxConverter.ocx
    '
    ' Edit the following line to change the "theme" of
    ' your background. Double-click this file to run it.
    '----------------------------------------------------
    strQuery = "landscape"


    '----------------------------------------------------
    ' the Yahoo! App ID -- Please don't change this
    '-----------------------------------------------------
    Const APP_ID = "ybackground"


    '----------------------------------------------------
    ' Using the query, find a random image via Yahoo!
    '-----------------------------------------------------
    'Construct a Yahoo! Search Query
    strReqURL = "http://api.search.yahoo.com/" & _
    "ImageSearchService/V1/imageSearch?" & _
    "appid=" & APP_ID & _
    "&query=" & strQuery & _
    "&results=50" & _
    "&adult_ok=0"


    'Start the XML Parser
    Set MSXML = CreateObject("MSXML.DOMDocument")


    'Set the XML Parser options
    MSXML.Async = False


    'Make the Request
    strResponse = MSXML.Load(strReqURL)
    If MSXML.parseError.errorCode <> 0 Then
    WScript.Echo("Error! " + MSXML.parseError.reason)
    End If


    'Make sure the request loaded
    If (strResponse) Then


    'Find the total available
    Set ResultSet = MSXML.SelectSingleNode("//ResultSet")
    intTotalReturned = ResultSet.getAttribute("totalResultsReturned")


    'Pick a random number
    Randomize
    RandomNumber = Int(intTotalReturned * Rnd + 1)


    'Load the results
    Set Results = MSXML.SelectNodes("//Result")


    'Loop through the results
    For x = 0 to Results.length - 1
    If x = RandomNumber Then


    strImageURL = Results(x).SelectSingleNode("Url").text
    End If
    Next


    'Unload the results
    Set Results = Nothing
    Set ResultSet = Nothing


    End If


    'If no image URL is found, send a message
    If strImageURL = "" Then
    WScript.Echo "No image found! Try again."
    WScript.Quit
    End If


    '----------------------------------------------------
    ' Save the image locally to the root c:\ folder
    '-----------------------------------------------------
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set xmlhttp = CreateObject("Msxml2.SERVERXMLHTTP")
    xmlhttp.Open "GET", strImageURL, false
    xmlhttp.Send(Now)


    fs.CreateTextFile "c:\" & strImageFile & ".jpg"


    'Create a Stream instance
    Dim objStream
    Set objStream = CreateObject("ADODB.Stream")


    'Open the stream
    objStream.Open
    objStream.Type = 1 'adTypeBinary
    objStream.Write xmlhttp.responseBody
    objStream.SaveToFile "c:\" & strQuery & ".jpg", 2 'adSaveCreateOverwrite
    objStream.Close
    Set objStream = Nothing
    Set xmlhttp = Nothing
    Set fs = Nothing


    '----------------------------------------------------
    ' Convert the jpeg to a bitmap
    '-----------------------------------------------------
    Set Converter = CreateObject("Gfx.Converter")
    Converter.ToBitmap "c:\" & strQuery & ".jpg", "c:\" & strQuery & ".bmp"
    Set Converter = Nothing


    '----------------------------------------------------
    ' Set the newly created bitmap to background
    ' and refresh
    '----------------------------------------------------
    strRegRoot = "HKEY_CURRENT_USER\Software\Microsoft\" & _
    "Internet Explorer\ Desktop\General\"
    strRegRoot2 = "HKEY_CURRENT_USER\Control Panel\Desktop\"


    Set Shell = WScript.CreateObject("Wscript.Shell")
    Shell.RegWrite strRegRoot & "BackUpWallpaper", "c:\" & strQuery & ".bmp"
    Shell.RegWrite strRegRoot & "Wallpaper", "c:\" & strQuery & ".bmp"
    Shell.RegWrite strRegRoot2 & "Wallpaper", "c:\" & strQuery & ".bmp"
    Shell.Run "%windir%\System32\RUNDLL32.EXE " & _
    "user32.dll,UpdatePerUserSystemParameters", 1, False
    Set Shell = Nothing




    Note that the first line of the script sets the theme of your desktop
    background. If you'd like something different from landscape images,
    simply edit this line to whatever you'd like to see.


    Also keep in mind that you can tweak the request URL variable strReqURL to
    get different results. The URL is currently set to exclude adult images:
    adult_ok is set to 0. If you change this value to 1, you might find adult
    images in your results. Of course, changing the strReqURL value to
    something more adult-oriented will have an effect on the content of the
    search as well. Even with the filter set to keep adult images out,
    understand that Yahoo!'s filter isn't perfect and some adult images might
    find their way into the mix.


    5.8.2. Running the Hack


    Before you run the script, make sure you understand the risks. This will
    replace your current desktop background with a random image from the Web,
    so be sure you have a backup of your current desktop background image
    before you proceed; otherwise, you might lose it forever. Also, remember
    that you're grabbing images from any web site; while the risk is minimal,
    some malicious code can find its way into image files. Make sure your
    antivirus program is up-to-date before playing around with this code.


    When you're ready to run the script, double-click the script file or run
    it from the command line:


    Y!Background.vbs




    You should see your desktop background change. If you're not happy with
    the image, run the script again. You can keep running the script until you
    settle on something you likefor example, the nice landscape in Figure
    5-16.




    Figure 5-16. A random Windows desktop background via Yahoo!





    If you want the random fun to continue, you can place this script in your
    Startup folder and you'll find a new background every time you log in to
    your machine. The Startup folder is located at C:\Documents and
    Settings\\Start Menu\Programs\.


    5.8.3. Hacking the Hack


    For even more random desktop background fun, add the script as a scheduled
    task by selecting Start Settings Control Panel Scheduled Tasks and
    choosing Add Scheduled Task. You can set it to run as frequently as you'd
    like, from once a week to once an hour.


    Leaving your desktop background to chance is definitely a risky game, but
    you might find some great images from across the Web in the process.















    Hack 84. Randomize Your Mac Desktop Background





    Leave your Mac desktop picture to chance with Yahoo!, Perl, and
    AppleScript.


    Windows users aren't the only ones who can experience the fun that is
    random desktop backgrounds [Hack #83]. By using Yahoo! as your own image
    database, you can automatically change your Mac desktop background picture
    when the mood strikes.


    If you use Mac OS X just to browse the Web and send email, you might not
    be aware that there's a powerful Unix-based operating system under the
    hood. In fact, in addition to AppleScript (the Mac scripting language),
    Mac OS X ships with Perl installed. This hack takes advantage of both Perl
    and AppleScript to bring some randomness to your desktop.


    5.9.1. The Code


    Perl is a great language for making HTTP requests and working with the
    responses. But it's not as good as AppleScript at performing Mac system
    tasks, such as setting a desktop image. Luckily, a Perl module called
    Mac::AppleScript lets you execute AppleScript code from within your Perl
    scripts. To install this module, open a Terminal window and type the
    following command:


    sudo perl -MCPAN -e 'install Mac::AppleScript'




    Before you begin, you'll need to install a couple of other Perl modules.
    As with most of the Perl examples in this book, you'll need LWP::Simple
    and XML::Simple to make Yahoo! requests and parse responses.


    Once these prerequisites are installed, save the following code to a file
    named ybackground.pl:


    #!/usr/bin/perl
    # ybackground.pl
    # Accepts a query term and sets a Mac desktop background
    # with that theme.
    # Usage: ybackground.pl
    #
    # You can read the full documentation
    # for Yahoo! Web Services at http://developer.yahoo.net/


    use strict;
    use LWP::Simple;
    use XML::Simple;
    use Mac::AppleScript qw(RunAppleScript);


    # Please leave this Yahoo! Application ID
    my $appID = "ybackground-mac";


    # Grab the incoming search query
    my $query = join(' ', @ARGV) or die "Usage: ybackground.pl \n";


    # Construct a Yahoo! Search Query with only required options
    my $language = "en";
    my $req_url = "http://api.search.yahoo.com/";
    $req_url .= "ImageSearchService/V1/imageSearch?";
    $req_url .= "appid=$appID";
    $req_url .= "&query=$query";
    $req_url .= "&results=50";
    $req_url .= "&adult_ok=0";


    # Make the request
    my $yahoo_response = get($req_url);


    # Parse the XML
    my $xmlsimple = XML::Simple->new();
    my $yahoo_xml = $xmlsimple->XMLin($yahoo_response);


    # Grab a random image URL from the results
    my $rnd = int(rand(@{$yahoo_xml->{Result}}));
    my $url = $yahoo_xml->{Result}->[$rnd]->{Url};


    # Save the image locally
    my $time = time;
    my $image = get($url);
    open IMAGE,">$query-$time.jpg";
    print IMAGE $image;
    close IMAGE;


    # Set the image as the current
    # desktop background


    RunAppleScript(qq(
    tell application "Finder"
    set desktop picture to document file "$query-$time.jpg"
    end tell));




    This code creates a unique image file each time the script is run, using
    the time the file was downloaded as part of the title. The last four lines
    of the script are where the AppleScript runs, via the RunAppleScript
    function, setting the desktop background to the newly downloaded file.


    If you know the specific size of an image you'd like to download, you can
    modify the script to look for that size. For example, if your desktop size
    is set to 1024 x 768, a smaller image that's stretched might not look as
    good as an image that is 1024 x 768 without resizing.


    To find only images that are a certain size you can use the height: and
    width: meta keywords when you construct the Yahoo! URL. If you only want
    images that are 1024 pixels wide, change the line in the script where you
    set the query, like so:


    $req_url .= "&query=$query width:1024";




    With the width set appropriately, you'll be sure to get only images that
    fit the width of your desktop.


    5.9.2. Running the Hack


    You can run the script from the command line, adding a desktop theme, like
    this:


    perl ybackground.pl insert theme




    Running the script with the lightning search term sets your background to
    something that looks like Figure 5-17.




    Figure 5-17. A random Mac desktop background via Yahoo!





    While the idea of leaving your desktop background to chance might seem
    frightening, you might be surprised at the quality of some of the images
    Yahoo! has found across the Web.
















    Hack 85. Mash Up Images from Around the Web





    The Yahoo! Image API provides access to thousands of images across the
    Web, and developers are recombining these images into new applications
    that let you play along.


    In the music world, a mash-up combines two or more existing songs into
    something entirely new. A mash-up might have a song from the Beatles in
    the background and vocals from Snoop Dogg in the foreground, while
    blending in a Sesame Street song at the same time. The Yahoo! Image Search
    web service offers programmatic access to thousands of images, and some
    developers are using this service to create their own visual
    mash-upscombining disparate images into games, interesting visualizations,
    or random works of art. Here are a few interactive examples that will give
    you a taste of what's being mashed together with the Yahoo! Image Search
    API.


    5.10.1. Yahoo! Buzz Demo


    The Yahoo! Buzz Demo is an alternative way to read the news. When you
    browse to http://buzz.progphp.com/, you'll find an oval-shaped collage
    made up of over 100 different images, each representing a current top news
    story. As you move your pointer over each image in the collage, the image
    pops to the foreground so that you can see it clearly, and a summary of
    the news story the image represents is displayed in the middle of the
    page, as shown in Figure 5-18.


    Clicking an image takes you directly to that image's original location on
    the Web, and clicking the center news story takes you to the full story at
    Yahoo! News. In addition to top stories, you can browse images based on
    other news categories, or use your own term.


    Rasmus Lerdorf, a Yahoo! employee, built the Yahoo! Buzz Demo to show
    what's possible with the Yahoo! Image Search web service. The demo uses
    PHP to pull in news stories from Yahoo! News RSS and the Yahoo! News API,
    images from around the Web via the Yahoo! Image API, and some crafty CSS
    to pull everything together. While it won't replace the front page of the
    paper anytime soon, the Buzz Demo is a fun way to find stories. If you'd
    like to take a look behind the scenes, you can view the complete source
    code at http://buzz.progphp.com/buzz.phps.


    5.10.2. Search Collage Generator


    Siddharth Uppal put together around 100 lines of Perl that grabs up to 50
    images for any given query and assembles them into a single collage. He
    used the existing Yahoo::Search module (available at
    http://search.cpan.org/~jfriedl/Yahoo-Search-1.4.7/lib/Yahoo/Search.pm) to
    assemble Yahoo! Image




    Figure 5-18. A visual look at top news stories





    API requests and return the results as Perl-friendly objects. The script
    then puts each image into a collage on a web page, resizing each image to
    the same size within HTML tags.


    You can download a copy of the script at
    http://upster.blogspot.com/2005/03/yahoo-image-search-collage-generator.html
    and run it from the command line like this:


    perl yahoo_collage.pl --query insert query




    The output is HTML, so you'll want to send this output to a new file. For
    example, you can create a collage of portraits from around the Web by
    calling the script like this:


    perl yahoo_collage.pl --query portrait > portrait.html




    After you run this script, portrait.html will show you a collage similar
    to the one in Figure 5-19.


    The script also provides the HTML necessary to share your collage with the
    world. You can simply cut and paste the HTML in the



    Relation:



      Search Engine:





    }




    This code makes sure that if the text parameter has not been submitted,
    the script presents a