-1
我正在用php寫一個bot。我想用curl來獲取圖像源。我可以得到img標籤,但是我無法從img獲得src值。總是我得到空的字符串。你能看到我的錯誤是什麼?PHP preg_match_all無法獲取img src
的index.php
$baglan = Baglan("http://www.hurriyetemlak.com/konut-satilik/sakarya-karasu-yali-emlakcidan-apartman-dairesi/detay/23585876");
preg_match('#<div id="dvSmallPhoto" class="small-photo mt10"> <ul class="thumbs">(.*?) </ul> </div>#', $baglan, $resimlerGenel);
preg_match_all('#<li><figure>(.*?)</figure></li>#', $resimlerGenel[1], $resimler);
$yeni = str_replace('"', '\'', $resimlerGenel[1]);
preg_match_all("#<li><figure><img src='(.*?)' href='JavaScript:void(0);' onclick='return replaceImg(this)' tabindex='(.*?)' class='pretty' width='114' height='88' alt='(.*?)' /></figure></li> #", $yeni, $resimLinkler);
print_r($resimLinkler);
Baglan.php
function Baglan($url){
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_USER_AGENT, $_SERVER["HTTP_USER_AGENT"]);
$cikti = curl_exec($curl);
curl_close($curl);
return str_replace(array("\n","\t","\r"), null, $cikti);
}