Esempio n. 1
0
 public function test()
 {
     $xml = new \SimpleXMLElement(file_get_contents('http://www.bbc.com/vietnamese/index.xml'));
     $data = NULL;
     $html = new Htmldom();
     foreach ($xml->entry as $key => $val) {
         $link = (string) $val->link['href'];
         $obj = $html->file_get_html($link);
         if (!isset($obj->find('div[property=articleBody]')[0])) {
             $body = $obj->find('div.map-body')[0]->outertext;
         } else {
             $body = $obj->find('.story-body__inner')[0]->outertext;
         }
         $data[$link]['content'] = $body;
         $data[$link]['title'] = (string) $val->title;
         $data[$link]['description'] = (string) $val->summary;
         $data[$link]['category'] = (string) $val->category[1]['label'];
         $data[$link]['image'] = $obj->find('meta[property=og:image]')[0]->content;
     }
     dd($data);
     #dd($curl->get(array_keys($data)[0],"://",30,0));
     #$this->data['data'] = $data ;
     $this->data['content'] = 'layouts.admin.pages.local.test';
     return $this->output('admin', false);
 }
Esempio n. 2
0
 /**
  * @param string $url URL or path to file content
  * @return object Dom
  */
 public function domFromFile($url)
 {
     return parent::file_get_html($url);
 }