想擷取圖片的網址為http://www.bsobs.com.tw/photos/index/y/2017/m//page/
目前這支程式可以跑出第一頁的圖片結果
如果要跑出所有分頁的結果我應該怎麼寫呢嗚嗚嗚
跪求高手救援,小弟只是新手阿阿~~~
<?php
//引入套件
require('C:\snoopy\Snoopy.class.php');
require('C:\phpquery\phpQuery\phpQuery.php');
//download url
$url = "http://www.bsobs.com.tw/photos/index/y/2017/m//page/";
//模仿正常人
$snoopy->agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36";
$snoopy->referer = "http://www.bsobs.com.tw/photos/index/y/2017/m//page/";
//擷取HTML
$snoopy = new Snoopy();
$html = $snoopy->fetch($url)->getResults();
//篩選img class
phpQuery::newDocumentHTML($html);
$images = pq('.photos_mobile img');
foreach($images as $image){
preg_match_all("#(http://images/babyphoto/\w+.JPG)#", $html,
$matches);//套用原圖網址
echo $image->getAttribute('src') ."<br>";
}
?>