Ejemplo n.º 1
0
 public function getMovie()
 {
     $html = new \Htmldom('http://www.google.com.au/movies?near=bangalore');
     print '<pre>';
     foreach ($html->find('#movie_results .theater') as $div) {
         print "Theate:  " . $div->find('h2 a', 0)->innertext . "\n";
         print "Address: " . $div->find('.info', 0)->innertext . "\n";
         foreach ($div->find('.movie') as $movie) {
             print "\tMovie:    " . $movie->find('.name a', 0)->innertext . '<br />';
             print "\tTime:    " . $movie->find('.times', 0)->innertext . '<br />';
         }
         print "\n\n";
     }
     $html->clear();
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //
     $html = new \Htmldom('http://www.google.com.au/movies?near=bangalore');
     print '<pre>';
     foreach ($html->find('#movie_results .theater') as $div) {
         print "Theate:  " . $div->find('h2 a', 0)->innertext . "\n";
         print "Address: " . $div->find('.info', 0)->innertext . "\n";
         foreach ($div->find('.movie') as $movie) {
             print "\tMovie:    " . $movie->find('.name a', 0)->innertext . '<br />';
             print "\tTime:    " . $movie->find('.times', 0)->innertext . '<br />';
         }
         print "\n\n";
     }
     $html->clear();
     $list = array(["title" => 'Reggae', "id" => 1], ["title" => 'Chill', "id" => 2], ["title" => 'Dubstep', "id" => 3], ["title" => 'Indie', "id" => 4], ["title" => 'Rap', "id" => 5], ["title" => 'Cowbell', "id" => 6]);
     echo json_encode($list);
 }
Ejemplo n.º 3
0
 function str_get_html($str, $lowercase = true, $forceTagsClosed = true, $target_charset = 'UTF-8', $stripRN = true, $defaultBRText = "\r\n", $defaultSpanText = " ")
 {
     $dom = new Htmldom(null, $lowercase, $forceTagsClosed, $target_charset, $stripRN, $defaultBRText, $defaultSpanText);
     if (empty($str) || strlen($str) > 600000) {
         $dom->clear();
         return false;
     }
     $dom->load($str, $lowercase, $stripRN);
     return $dom;
 }