public function index() { $this->load->library('curl'); $this->curl->referer('m.detik.com'); $this->curl->userAgent('midp 2.0'); $html = $this->curl->openGet("http://m.detik.com"); $elements = array(); $this->load->helper('dom'); $dom = str_get_html($html); // parsing headline if ($needle = $dom->find('div[id=framehead]', 0)) { $href = $needle->find('a', 0)->href; $href = $this->normalize_href($href); $href = encode_href($href); $judul3 = $needle->find('a', 0); $description = trim($judul3->plaintext); $description = normalize_html($description); $name = string_to_word($description, 3); array_push($elements, array('name' => $name, 'description' => $description, 'value' => $href)); } // parsing berita setelah headline foreach ($needle->find('div[class=nonhl]') as $h3) { $a = $h3->find('a', 0); $href = $this->normalize_href($a->href); $href = encode_href($href); $description = trim($a->innertext); $description = normalize_html($description); $name = string_to_word($description, 3); array_push($elements, array('name' => $name, 'description' => $description, 'value' => $href)); } $this->load->library('rafa'); $this->rafa->addHeading('detik'); $this->rafa->addList('news', $elements); $this->rafa->endRafa(); }
public function index() { $this->load->library('curl'); $this->curl->referer('m.okezone.com'); $this->curl->userAgent('midp 2.0'); $html = $this->curl->openGet("http://m.okezone.com"); $elements = array(); $this->load->helper('dom'); $dom = str_get_html($html); // parsing berita headline for ($i = 0; $i < 2; $i++) { if ($headline = $dom->find('div[class=hl]', $i)) { $href = $headline->find('a', 0)->href; $href = $this->normalize_href($href); $href = encode_href($href); //echo $href; //die(); $judul3 = $headline->find('a', 0); $description = trim($judul3->plaintext); $description = normalize_html($description); $name = string_to_word($description, 3); array_push($elements, array('name' => $name, 'description' => $description, 'value' => $href)); } } // parsing berita setelah headline $ul = $dom->find('div[class=b]', 1); foreach ($ul->find('li') as $li) { $a = $li->find('a', 0); $href = $this->normalize_href($a->href); $href = str_replace('/', '.', $href); $description = trim($a->innertext); $description = normalize_html($description); $name = string_to_word($description, 3); array_push($elements, array('name' => $name, 'description' => $description, 'value' => $href)); } $this->load->library('rafa'); $this->rafa->addHeading('okezone'); $this->rafa->addList('news', $elements); $this->rafa->endRafa(); }
public function index() { $this->load->library('curl'); $this->curl->referer('m.vivanews.com'); $this->curl->userAgent('midp 2.0'); $html = $this->curl->openGet("http://m.vivanews.com"); $elements = array(); $this->load->helper('dom'); $dom = str_get_html($html); // parsing judul berita $table = $dom->find('table', 0); foreach ($table->find('<span class="judul">') as $span) { $a = $span->find('a', 0); $href = $this->normalize_href($a->href); $description = trim($a->innertext); $description = normalize_html($description); $name = string_to_word($description, 3); array_push($elements, array('name' => $name, 'description' => $description, 'value' => $href)); } $this->load->library('rafa'); $this->rafa->addHeading('vivanews'); $this->rafa->addList('news', $elements); $this->rafa->endRafa(); }