$index_page = file_get_contents('http://www.sina.com.cn'); $rule = '@<a.*?href=("|/'|)([^/'"#{};/s]+)("|/'|).*?>@ims'; preg_match_all($rule,$index_page,$out); $all_index_urls = $out[2]; if(!empty($all_index_urls)){ foreach($all_index_urls as $k =>$url){ if(strpos($url,':void(') !== false){ unset($all_index_urls[$k]); } } } echo '<pre>'; print_r($all_index_urls); echo '</pre>';