我打电话给
http://data.alexa.com/data?cli=10&dat=snbamz&url=www.flipkart.com获取网站数据,当我在浏览器上运行它显示这个XML.
<ALEXA VER="0.9" URL="flipkart.com/" HOME="0" AID="=" IDN="flipkart.com/"> <RLS PREFIX="http://" more="0"> <RL HREF="storewala.com/" TITLE="Storewala.com - Indian Retail Store"/> <RL HREF="pdf-search-engine.com/" TITLE="Ebook Search - Pdf Search Engine"/> <RL HREF="overnitenet.com/" TITLE="-----Overnite-----"/> <RL HREF="nbcindia.com/" TITLE="Online Book Stores,India's Largest Bookstore,Nbc India.com"/> <RL HREF="mouthshut.com/" TITLE="Mouthshut.com - Consumer Reviews Helping You Decide"/> <RL HREF="landmarkonthenet.com/" TITLE="Land Mark"/> <RL HREF="ingrambook.com/" TITLE="Ingram Book Group"/> <RL HREF="infibeam.com/" TITLE="InfiBeam - Gifts to India | Online Shopping India | Books,Cameras,Watches,Mob"/> <RL HREF="indiaplaza.in/" TITLE="Fabmall House"/> <RL HREF="firstflight.net/" TITLE="FirstFlight Courier"/> </RLS> <SD TITLE="A" FLAGS="" HOST="flipkart.com"> <TITLE TEXT="Flipkart.com"/> <OWNER NAME="Flipkart.com"/> </SD> <SD> <POPULARITY URL="flipkart.com/" TEXT="116" SOURCE="panel"/> <REACH RANK="130"/> <RANK DELTA="+5"/> <COUNTRY CODE="IN" NAME="India" RANK="8"/> </SD> </ALEXA>
我正在取得人气和国家排名.
$xml = simplexml_load_file('http://data.alexa.com/data?cli=10&dat=snbamz&url=www.flipkart.com'); $rank=isset($xml->SD[1]->POPULARITY)?$xml->SD[1]->POPULARITY->attributes()->TEXT:0; $country_rank=isset($xml->SD[1]->COUNTRY)?$xml->SD[1]->COUNTRY->attributes()->RANK:0;
我希望它能帮助你.
$xml = simplexml_load_file('http://data.alexa.com/data?cli=10&dat=snbamz&url=www.flipkart.com'); foreach($xml->RLS->children() as $key => $val){ $href = (string)($val->attributes()->HREF); $title= (string)($val->attributes()->TITLE); echo 'HREF : ' . $href . ' TITLE: ' . $title . '<br />'; }