example_scraping_slashdot.php in simplehtmldom API 5.2
File
simplehtmldom/example/scraping/example_scraping_slashdot.php
View source
<?php
include_once '../../simple_html_dom.php';
function scraping_slashdot() {
$html = file_get_html('http://slashdot.org/');
foreach ($html
->find('div[id^=firehose-]') as $article) {
$item['title'] = trim($article
->find('a.datitle', 0)->plaintext);
$item['body'] = trim($article
->find('div.body', 0)->plaintext);
$ret[] = $item;
}
$html
->clear();
unset($html);
return $ret;
}
$ret = scraping_slashdot();
foreach ($ret as $v) {
echo $v['title'] . '<br>';
echo '<ul>';
echo '<li>' . $v['body'] . '</li>';
echo '</ul>';
}