网页资源抓取

// $text=file_get_contents('http://huaban.com/');
// preg_match_all('/<img[^>]*>/i', $text, $match);
// print_r($text);
$keyword = "火影";
$keyword = urlencode($keyword);
$url = "www.baidu.com";
$html = file_get_contents($url);
preg_match_all("/\"[^\"]*[^0]\.jpg\"/", $html, $text);
foreach ($text as $key => $value) {
foreach ($value as $img) {
$a='www.baidi.com';
$img=substr($img, 1,strlen($img)-2);
// $img=$a.$img;
// var_dump($img);
print "<img src=".$a.$img . " /><br/>";
 
 
}
}
posted @ 2017-05-02 10:48  木辰于  阅读(624)  评论(0编辑  收藏  举报