タグのsrc
属性の内容を取得したい。<img>
私が使用しているコードは次のとおりです。
require_once( 'simple_html_dom.php');
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $webpage);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);
$str = curl_exec($curl);
curl_close($curl);
if( $str )
{
$html= str_get_html($str);
$img = $html->find('img', 0); // get the first image on the page
$src = $img->src; // get the contents of the img src - but it doesn't seem to work
}
私は何を間違っていますか?