PHP爬取百度图片

来源:互联网 发布:中金公司 知乎 编辑:程序博客网 时间:2024/06/08 19:44


<?php        //搜索指定关键词的百度图片并显示        $keyword = "海鸥";        $keyword = urlencode($keyword);        $url = "http://image.baidu.com/search/index?tn=baiduimage&word=" . $keyword;        $html = file_get_contents($url);        preg_match_all("/\"[^\"]*[^0]\.jpg\"/", $html, $text);        foreach ($text as $key => $value) {            foreach ($value as $img) {                print "<img src=" . $img . " />";            }        }        ?>


0 0
原创粉丝点击