$doc = new DOMDocument();
$filepath="http://life.tenpay.com/cgi-bin/mobile/MobileQueryAttribution.cgi?chgmobile=15238275006";//返回数据为xml格式的
$doc->load($filepath);
//解析xml数据,得到需要的数据,这里我只需要得到省市,即可
$books = $doc->getElementsByTagName("root");
foreach($books as $book)
{
$provinces = $book->getElementsByTagName("province");
$province = $provinces->item(0)->nodeValue;
$citys = $book->getElementsByTagName("city");
$city = $citys->item(0)->nodeValue;
$usercity=trim($province).",".trim($city);
}
下面为返回数据格式
-
/cgi-bin/mobile/MobileQueryAttribution.cgi
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; .NET CLR 1.1.4322; InfoPath.2; Tablet PC 2.0)
117.85.147.186
chgmobile=15238275006
GET
http://write.blog.csdn.net/postedit
15238275006
平顶山
河南
0
OK
移动