php 抓取页面数据

来源:互联网 发布:自动识别颜色的软件 编辑:程序博客网 时间:2024/05/08 20:43

$url = 'http://product.dangdang.com/23812052.html';


$str = file_get_contents($url);//抓取函数


preg_match_all('/(?<=[<li tag=\"\d{1}\"> <a href=\"javascript:;\" imghref=\".*\">]) <img[^>]*src=[\'"]*([^\'"]*)[\'"][^>]*>(?=[<\/a> <\/li>])/is', $str , $ar );//正则你想要的数据


$strs =array_unique($ar[1]);//移除数组中的重复值


var_dump($strs);
0 0
原创粉丝点击