最新消息:iOS编程开发交流群(6906921) ,Mac.Cocoa开发交流群(7758675) 欢迎iOS/macOS开发编程爱好及学习者加入!

php获取alexa排名数字正则表达式

PHP 天狐 8090浏览 0评论

最近在做站长工具,发现aleax的查询工具源码,获取世界排名时候后边总多了个尾巴" SOURCE="panel" 非常不爽

修正后的代码如下,增加了中国排名代码

$string = file_get_contents("http://data.alexa.com/data/+wQ411en8000lA?cli=10&dat=s&ver=7.0&url=$url");

$pat4 = "/POPULARITY URL=\"(.+)\" TEXT=\"(.+)\" SOURCE=\"(.+)\"\/>/Ui";
preg_match_all($pat4, $string, $array);	
$wordpm2 = $array[2][0]?$array[2][0]:'none';

print_r($wordpm2);

$string = file_get_contents("http://data.alexa.com/data/+wQ411en8000lA?cli=10&dat=s&ver=7.0&url=$url");
$pat4 = "/COUNTRY CODE=\"(.+)\" NAME=\"(.+)\" RANK=\"(.+)\"\/>/Ui";
preg_match_all($pat4, $string, $array);	
$cnpm2 = $array[3][0]?$array[3][0]:'none';
print_r($cnpm2);

 

转载请注明:天狐博客 » php获取alexa排名数字正则表达式

微信 OR 支付宝 扫描二维码
为天狐 打赏
非常感谢你的支持,哥会继续努力!
发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址