public function news($id) { $this->load->library('curl'); $this->curl->referer('m.detik.com/kanal/70/'); $this->curl->userAgent('midp 2.0'); $id = decode_href($id); $html = $this->curl->openGet("http://m.detik.com/read/" . $id); $this->load->helper('dom'); $dom = str_get_html($html); $content = $dom->find('div[id=content]', 0); if ($title = $content->find('h1', 0)) { $title = $title->innertext; } if ($needle = $content->find('p', 0)) { $strong = $needle->find('strong', 0); $name = $strong->innertext; $strong->outertext = ''; $img = $needle->find('img', 0); $img->outertext = ''; //echo $needle; //die(); $description = trim($needle->innertext); $name = normalize_html($name); $description = normalize_html($description); } $elements = array(array('name' => $name, 'description' => $description)); $this->load->library('rafa'); $this->rafa->addHeading('detikbola'); $this->rafa->addList('news', $elements, $title); $this->rafa->endRafa(); }
public function news($id) { $this->load->library('curl'); $this->curl->referer('www.goal.com/id-ID/news/'); $this->curl->userAgent('midp 2.0'); // Harus terdapat parameter terakhir tetapi terserah $id = decode_href($id); $url = "http://www.goal.com/id-ID/news/" . $id; $html = $this->curl->openGet($url); $this->load->helper('dom'); $dom = str_get_html($html); $title = $dom->find('h1', 0)->innertext; $name = $dom->find('h4', 0)->innertext; if ($needle = $dom->find('span[id=divAdnetKeyword]', 0)) { // Hapus text yg tidak penting foreach ($needle->children() as $child) { $tag = strtolower($child->tag); if ($tag != 'br' && $tag != 'em') { $child->outertext = ''; } } $description = trim($needle->innertext); $description = normalize_html($description); } $elements = array(array('name' => $name, 'description' => $description)); $this->load->library('rafa'); $this->rafa->addHeading('goal'); $this->rafa->addList('news', $elements, $title); $this->rafa->endRafa(); }