You are here

function scraping_digg in simplehtmldom API 7

Same name and namespace in other branches
  1. 5.2 simplehtmldom/example/scraping/example_scraping_digg.php \scraping_digg()
  2. 6 simplehtmldom/example/scraping/example_scraping_digg.php \scraping_digg()
1 call to scraping_digg()
example_scraping_digg.php in simplehtmldom/example/scraping/example_scraping_digg.php

File

simplehtmldom/example/scraping/example_scraping_digg.php, line 4

Code

function scraping_digg() {

  // create HTML DOM
  $html = file_get_html('http://digg.com/');

  // get news block
  foreach ($html
    ->find('div.news-summary') as $article) {

    // get title
    $item['title'] = trim($article
      ->find('h3', 0)->plaintext);

    // get details
    $item['details'] = trim($article
      ->find('p', 0)->plaintext);

    // get intro
    $item['diggs'] = trim($article
      ->find('li a strong', 0)->plaintext);
    $ret[] = $item;
  }

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