我是获取的新手,在代码中它说div[class="movies]/div/a
我试图在 div 之后使用 /a 获取所有标签,它只获取一个,请帮助我了解如何获取所有标签。
谢谢
<?php
include_once('../../simple_html_dom.php');
function scraping_IMDB($url) {
// create HTML DOM
$html = file_get_html($url);
// get title/
$ret['Title'] = $html->find('**div[class="movies]/div/a**', 0)->innertext;
// get rating
$ret['Rating'] = $html->find('div[class="DataWhite"] b', 0)->innertext;
// get overview
foreach($html->find('div[class="DataWhite"]') as $div) {
// skip user comments
if($div->find('h5', 0)->innertext=='User Comments:')
return $ret;
$key = '';
$val = '';
foreach($div->find('*') as $node) {
if ($node->tag=='h5')
$key = $node->plaintext;
if ($node->tag=='a' && $node->plaintext!='more')
$val .= trim(str_replace("\n", '', $node->plaintext));
if ($node->tag=='text')
$val .= trim(str_replace("\n", '', $node->plaintext));
}
$ret[$key] = $val;
}
// clean up memory
$html->clear();
unset($html);
return $ret;
}
// -----------------------------------------------------------------------------
// test it!
$ret = scraping_IMDB('http://www.tastekid.com/like/The+Help/movies');
foreach($ret as $k=>$v)
echo '<strong>'.$k.' </strong>'.$v.'<br>';
?>