0

サイトから正しいiframeを取得する際に問題が発生します。

これが私が使おうとしているコードです。私が抱えている問題は、これがコンテンツクラスのすべてを返すことです。クラスにあるiframeのみを返したいのですが。どんな助けでもいただければ幸いです。ありがとうございました。

<?php
include_once('../../simple_html_dom.php');
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"User-Agent: User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.52 Safari/536.5\r\n"
)
);

$context = stream_context_create($opts);

$html = file_get_html('http://www.tvshow7.eu/breaking-bad-season-1-episode-1-pilot/', false, $context);

foreach($html->find('.content') as $iframe) {

echo $iframe->outertext, PHP_EOL;
}

?>    
4

1 に答える 1

1

わかりました。わかりました。

<?php
include_once('../../simple_html_dom.php');


$html = file_get_html('http://www.tvshow7.eu/breaking-bad-season-1-episode-1-pilot/');

// find <p> and store varible
foreach($html->find('p') as $p)

// find iframe from within varibale $p
foreach($p->find('iframe') as $iframe)

echo $iframe->outertext . '<p>';

 // clean up memory
    $html->clear();
    unset($html);

?>
于 2013-01-06T12:23:23.780 に答える