Tải bản đầy đủ - 0 (trang)
Hack 15. Find Hot Technologies at the Buzz Game

Hack 15. Find Hot Technologies at the Buzz Game

Tải bản đầy đủ - 0trang

BuzzGamesitegivesyouagreatsnapshotofthecurrentstate

oftechnologyinaparticularindustry.Forexample,click

Marketsatthetopofthehomepageandbrowsethecategories

forPortableMediaDevices.Ataglance,youcanseethetop

contendersintheportablemediagadgetspace.Figure1-46

showstherelativemarketpricesforvariousMP3playersinApril

2005,withtheiPodclearlyaheadofthepack.

Clickingthrougheachentryinaparticularmarket,youcanget

asenseofhowgameplayersfeelabouteachproduct'schances

forsuccess.Ifyoubrowsethroughtheitemslistedunder

RumorMill,you'llseeproductsthatdon'texistyetandwhat

tech-headsarepredictingabouttheirchancesatexistence.

Eachcompanyorproducthasadetailpage,similartoastocktrackingpage,withthecurrentprice,itshistory,andoverall

buzzscore(seeFigure1-47).



Figure1-46.ThePortableMediaDevicesmarket

attheBuzzGame



Figure1-47.TheFlickrdetailpageattheYahoo!

BuzzGame



Thebuzzscoreisderivedviathesamemethodologyusedfor

theYahoo!BuzzIndex[Hack#14]scores,anditrepresents

thenumberofsearchesforthatparticularterm.Thedetailpage

includesrelatednewsaboutaparticulartechnology,thanksto

Yahoo!News,and,ifyou'replayingalong,aformthatletsyou

buyorsellshares.



1.16.2.BuzzGameAPI

Ifyou'dliketodoabitofyourownfantasymarketanalysis,

Yahoo!offersalloftheBuzzGamedataasXML.Thereare

severalwaystoaccessthedata,includingtwofilesthatoffer

mostoftheinformationinoneplace:



AllBuzzGamedatainonefile

Availableat

http://buzz.research.yahoo.com/bk/rest/allinfo.xml,thisfile

includesdataforeverymarketandstock.Eachstockentry

includesthestock'sinternalID,price,buzzscore,and

numberofshares,andeverymarketincludesthemarket

capitalization.



Allstockpricesinonefile

Thisisasimplifiedversionoftheabovefile,anditincludes

pricesofeachstockorganizedbymarket.Thisfileisat

http://buzz.research.yahoo.com/bk/rest/prices.xml.

Anotherwaytofinddataaboutindividualstocksistocreate

requestURLsthatcontainthestocksymbolandthesymbolfor

themarketthatstockbelongsto.Here'stheURLformatfor

lookingupindividualstocks:







http://buzz.research.yahoo.com/bk/rest/info.xml?markets

symbol&stocksymbol=insertstocksymbol



Soifyou'dliketofindoutwhattheiPodistradingat,youcan

visitthePortableMediaDevicesmarketdetailpage

(http://buzz.research.yahoo.com/bk/market/market.html?

_mid=6928)andfindthesymbolforthatmarket(PORTMEDIA)

atthetopofthepage.Abitfurtherdownthepage,you'llsee

thatthesymbolfortheindividualiPodstockis,appropriately,

IPOD.Knowingthesetwosymbols,youcangetanXML

representationoftheprice,buzzscore,andnumberofshares



availablewiththefollowingURL:





http://buzz.research.yahoo.com/bk/rest/info.xml?markets









stocksymbol=IPOD



Finally,youcanalsoaccessindividualstocksviatheirinternal

IDnumberwiththefollowingURLformat:





http://buzz.research.yahoo.com/bk/rest/info.xml?stockid



TofindastockIDforanyparticularstock,you'llfirstneedto

lookuptheIDviaoneoftheXMLfiles.



1.16.3.GraphingMarkets

OnepotentialuseoftheBuzzGameAPIistocreateyourown

chartsandgraphstospottrendsinthefantasymarket.Usinga

bitofPerltomovetheBuzzGamedataintoExcel,youcandon

yourgreenvisorandstartdoingyourownanalysisaboutwhere

toplaceyourbets.



1.16.3.1.Thecode.

Tousethiscode,you'llneedacopyofLWP::Simple,forfetching

theBuzzGamepage.Thisscriptacceptsamarketsymbol,

fetchestheprices.xmlfile,andloopsthroughthefilelookingfor

thespecificmarket.Oncethescriptfindsthemarket,itprints

thestocknamesandprintsacomma-separatedvaluelist

suitableforopeninginExcel.Togetstarted,savethefollowing



codetoafilecalledbuzz_excel.pl:



















#!/usr/bin/perl

#buzz_excel.pl

#AcceptsaBuzzGameMarketSymbolandreturnsaCSV

#listofstockpricesyoucanopeninExcel.

#Usage:buzz_excel.pl

#

#YoucanfindmarketIDs,andreadmoreabouttheBuzz

#athttp://buzz.rsearch.yahoo.com/











usestrict;

useLWP::Simple;

useData::Dumper;









#GrabtheincomingmarketID

my$msym=join('',@ARGV)ordie"Usage:buzz_excel.p









#SettherequestURL

my$buzz_url="http://buzz.research.yahoo.com/bk/rest/









#Maketherequest

my$prices=get($buzz_url);



















#Findthemarket

while($prices=~m!






!mgis){



my$market_name=$1;



print"\"$market_name\"\n\n";



my$stocks=$2;



while($stocks=~m!














*?)\n!mgis){





my$stock_symbol=$1;





my$stock_name=$2;





my$stock_price=$3;





print"\"$stock_name\",$stock_symbol,$s











}



}



1.16.3.2.Runningthehack.

Torunthecode,simplycallthescriptfromthecommandline,

addingyourrelevantmarketIDandchoosinganoutputfile:





perlbuzz_excel.plRUMOR>rumors.csv



Ifyouhaveaspreadsheetprogram,youshouldbeableto

double-clickrumors.csvtotakealookatthedata.Ifyou'dlike

towhipupasnazzypiechart,highlighttheblockofdataand

startthechartwizardbyselectingInsert Chart…,choosing

thepiecharttype,andfollowingtherestofthewizard'ssteps.

You'llendupwithaquickvisualizationofthemarket,asshown

inFigure1-48.



Figure1-48.BuzzGameRumorMillmarketpie

chartinMicrosoftExcel



Ataglance,youcanseethattheXbox360rumorhasthe

biggestsliceofthepieatthetimeofthiswriting(May2005).

Thisparticularanalysiswon'ttellyouwheretoplaceyourbets

inthegame,buthopefullyitshowshowyoucanstarttoplay

withthedatathisfantasymarketisgenerating.

TheYahoo!BuzzGamewon'treplacetraditionalmarket

researchforspottingtrends,butit'safunwaytakethepulseof

techgeeksandseewhatthey'repredicting.







Hack16.TameLongYahoo!URLs



WithaneyeforURLsandtherighttools,youcanshorten

longYahoo!URLswhenyouneedtosendthemviaemail.

Mostofthetime,we'reallsurfingtheWebinvirtualisolation.

It'sjustyouandthecomputer,andthelastthingonyourmind

isthelengthofaURLatapageyou'revisiting.Butassoonas

youwanttosharethepieceoftheWebyou'reviewingwith

someoneelse,thelengthofaURLbecomesimportant.

Becauseemailprogramswraptextat72characters(foreasy

reading),anyURLthat'slongercouldbebroken.AbrokenURL

meanssomeoneontheotherendofthemessagewon'tbeable

toseethepageyou'vesentthemorthattheywillhavetospend

aminuteortwopastingtheURLtogetherinNotepad.And

imaginetryingtohandwriteanotetosomeonethatincludes

someoftheURLsyoustumbleacross!



1.17.1.TrimmingYahoo!URLs

Yahoo!hasalotofgreatcontenttosharewithothers,butsome

oftheURLsaredefinitelytoolongtosendviaemail.Here'sa

Yahoo!LocalURLforapagethatshowsalistofcoffeeshopsin

Sebastopol,CA:





http://local.yahoo.com/results;_ylt=AvyPaC0wOiCme6J1PYb







ylu=X3oDMTBtbGZ2dXFpBF9zAzk2NjEzNzY3BHNlYwNzZWFyY2g-?st







csz=Sebastopol%2C+CA&fr=



Those154charactersintheURLaredefinitelypastthe72charactersafezone.IfyoutakealookattheURL,youcansee

somevariable/valuepairsthatcontaintherelevantinformation.

Thestring?stx=coffeelooksimportant,asdoes

csz=Sebastopol%2C+CA.ButtherestoftheURLlookslikegibberish.



It'simportanttonotethatwhatlookslikegibberishisactuallyuseful

informationtoYahoo!,butit'snotusefultoyouwhenyou'retryingto

sharelinks,soyoucancutitout.



CuttingthegarbagecharactersoutoftheURLwillgiveyou

somethingmoremanageable:





http://local.yahoo.com/results?stx=coffee&csz=Sebastopo



Iftheareayouwanttosearchissmallenough,youcaneven

useaZipCodeinsteadofthecityandstatecombination:





http://local.yahoo.com/results?stx=coffee&csz=95472



The51charactersinthisURLarewellwithinthesafezone,and

theURLpointstoexactlythesamepage.Ifyoufrequentlyfind

yourselfsharingpagesfromYahoo!Local,youmightwantto

pickupabookmarkletbyBrianCantoni(availableat

http://www.cantoni.org/2005/06/06/ylocal)thatautomatesthe

processofremovingthegarbagecharacters.Dragthe

bookmarkletlinktoyourtoolbar,andclickitanytimeyouwant

tosharealinktoYahoo!Local.Thebookmarkletopensanew



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Hack 15. Find Hot Technologies at the Buzz Game

Tải bản đầy đủ ngay(0 tr)

×