//调用ip方法判断地址
public static function get_info($ip)
{
// $url = "http://whois.pconline.com.cn/jsFunction.jsp?callback=jsShow&ip=" . $ip;
$url = "http://whois.pconline.com.cn/jsFunction.jsp?ip=" . $ip;
$ch = curl_init();
//设置选项,包括URL
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
//执行并获取HTML文档内容
$output = curl_exec($ch);
//释放curl句柄
curl_close($ch);
$info = iconv('GB2312', 'UTF-8', $output); //因为是js调用 所以接收到的信息为字符串,注意编码格式
//php 截取特定字符前面的内容
$aa = substr($info,0,strrpos($info,"省"));
//PHP 截取特定字符串后面的内容
$bb = substr($aa,strripos($aa,"'")+1);
return $bb;
}
|