function scraping_slashdot in simplehtmldom API 6
Same name and namespace in other branches
- 5.2 simplehtmldom/example/scraping/example_scraping_slashdot.php \scraping_slashdot()
- 7 simplehtmldom/example/scraping/example_scraping_slashdot.php \scraping_slashdot()
1 call to scraping_slashdot()
- example_scraping_slashdot.php in simplehtmldom/
example/ scraping/ example_scraping_slashdot.php
File
- simplehtmldom/
example/ scraping/ example_scraping_slashdot.php, line 4
Code
function scraping_slashdot() {
// create HTML DOM
$html = file_get_html('http://slashdot.org/');
// get article block
foreach ($html
->find('div[id^=firehose-]') as $article) {
// get title
$item['title'] = trim($article
->find('a.datitle', 0)->plaintext);
// get body
$item['body'] = trim($article
->find('div.body', 0)->plaintext);
$ret[] = $item;
}
// clean up memory
$html
->clear();
unset($html);
return $ret;
}