File "example_scraping_slashdot.php"

Full path: /home/kosmetik/public_html/api/price_hunt/example/scraping/example_scraping_slashdot.php
File size: 584 B
MIME-type: text/x-php
Charset: utf-8

Download   Open   Edit   Advanced Editor   Back

<?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>';
}