Twitter から画像の URL をスクレイピングしようとしています。次の php コードと file_get_contents が機能していることがわかりましたが、正規表現が URL と一致しているとは思いません。このコードのデバッグを手伝ってもらえますか? 前もって感謝します。
これは、画像を含む twitter のスニペットです。
<div class="media-gallery-image-wrapper">
<img class="large media-slideshow-image" alt="" src="https://pbs.twimg.com/media/BGZHCHwCEAACJ19.jpg:large" height="480" width="358">
</div>
phpコードは次のとおりです。
<?php
$url = 'http://t.co/s54fJgrzrG';
$twitter_page = file_get_contents($url);
preg_match('/(http:\/\/p.twimg.com\/[^:]+):/i', $twitter_page, $matches);
$imgURL = array_pop($matches);
echo $imgURL;
?>