21,886
社区成员
发帖
与我相关
我的任务
分享
function ranger($url){
$headers = array( "Range: bytes=0-32768" );
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
return curl_exec($curl);
curl_close($curl);
}//curl设置
require dirname(__FILE__) . '/simple_html_dom.php';
//采用simple_html_dom.php分析HTML nod
$url = 'http://www.huffingtonpost.com/';
$html = file_get_html($url);
if($html->find('img')){
foreach($html->find('img') as $element) {
$raw = ranger($element->src);
$im = @imagecreatefromstring($raw);
$width = @imagesx($im);
$height = @imagesy($im);
if($width>=200||$height>=200){
echo $element;//得出长大于大于200,宽大于等于200的图片
}
}
}