求助正责表达式
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> <?php $str = getHtml('http://www.youku.com/show_page/id_z70846538ce0311e0a046.html'); $str = iconv('utf-8','gbk',$str); preg_match_all('/<div class="pack_thumb">([\s\S]*?)/isU' ,$str , $match); preg_match_all('/href="([\s\S]*?)"/' , $match[1][0], $href ); print_r($href);exit(); function getHtml($url){ if(function_exists('file_get_contents')){ $file_contents = file_get_contents($url); } else{ $ch = curl_init(); $timeout = 5; curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $file_contents = curl_exec($ch); curl_close($ch); } return $file_contents; }
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> [0] => http://v.youku.com/v_show/id_XMzA0NjA4MjA4.html [1] => http://v.youku.com/v_show/id_XMzA0NjA4MjA4.html [2] => http://v.youku.com/v_show/id_XMzA2NTYxNDIw.html [3] => http://v.youku.com/v_show/id_XMzA2NTYxNDIw.html [4] => http://v.youku.com/v_show/id_XMzA4NTQ4NjE2.html [5] => http://v.youku.com/v_show/id_XMzA4NTQ4NjE2.html [6] => http://v.youku.com/v_show/id_XMzEwNTQyNDM2.html [7] => http://v.youku.com/v_show/id_XMzEwNTQyNDM2.html [8] => http://v.youku.com/v_show/id_XMzEyNjE3OTAw.html [9] => http://v.youku.com/v_show/id_XMzEyNjE3OTAw.html [10] => http://v.youku.com/v_show/id_XMzE0NzM4Mjky.html [11] => http://v.youku.com/v_show/id_XMzE0NzM4Mjky.html [12] => http://v.youku.com/v_show/id_XMzE2OTU0NTgw.html [13] => http://v.youku.com/v_show/id_XMzE2OTU0NTgw.html [14] => http://v.youku.com/v_show/id_XMzE5MjcyMTY4.html [15] => http://v.youku.com/v_show/id_XMzE5MjcyMTY4.html [16] => http://v.youku.com/v_show/id_XMzIxNDk2NDcy.html [17] => http://v.youku.com/v_show/id_XMzIxNDk2NDcy.html [18] => http://v.youku.com/v_show/id_XMzQwMjAxNzgw.html [19] => http://v.youku.com/v_show/id_XMzQwMjAxNzgw.html [20] => http://v.youku.com/v_show/id_XMzQyNTE2OTA4.html [21] => http://v.youku.com/v_show/id_XMzQyNTE2OTA4.html [22] => http://v.youku.com/v_show/id_XMzQ0Njk1NDk2.html [23] => http://v.youku.com/v_show/id_XMzQ0Njk1NDk2.html [24] => http://v.youku.com/v_show/id_XMzQ4NDIyMTI0.html [25] => http://v.youku.com/v_show/id_XMzQ4NDIyMTI0.html [26] => http://v.youku.com/v_show/id_XMzUxMDI3ODg0.html [27] => http://v.youku.com/v_show/id_XMzUxMDI3ODg0.html [28] => http://v.youku.com/v_show/id_XMzUzMzUzMjc2.html [29] => http://v.youku.com/v_show/id_XMzUzMzUzMjc2.html [30] => http://v.youku.com/v_show/id_XMzY2NTk3MTU2.html [31] => http://v.youku.com/v_show/id_XMzY2NTk3MTU2.html [32] => http://v.youku.com/v_show/id_XMzY5OTM1MzAw.html [33] => http://v.youku.com/v_show/id_XMzY5OTM1MzAw.html [34] => http://v.youku.com/v_show/id_XMzczNTE4NTA4.html [35] => http://v.youku.com/v_show/id_XMzczNTE4NTA4.html [36] => http://v.youku.com/v_show/id_XMzAwMDk4NDM2.html [37] => http://v.youku.com/v_show/id_XMzAwMDk4NDM2.html [38] => http://v.youku.com/v_show/id_XMzA0MTE1MzQw.html [39] => http://v.youku.com/v_show/id_XMzA0MTE1MzQw.html [40] => http://v.youku.com/v_show/id_XMjcwMDMwMDc2.html [41] => http://v.youku.com/v_show/id_XMjcwMDMwMDc2.html [42] => http://v.youku.com/v_show/id_XMzA0Njg4MDIw.html [43] => http://v.youku.com/v_show/id_XMzA0Njg4MDIw.html <div class="clear"> </div>