title: Youtube Scraper with Php
body: <p>I'm a rookie programmer, trying to find his footing in PHP and i currently want to build a You-tube scraper.</p>
  
  <p>This scraper would search You-tube for a key word, say "drop shipping", and return a list of links bearing that keyword in their title.</p>
  
  <p>so far this is what i got:
      
  
  <pre><code>require('simple_html_dom.php');
  
  $html = file_get_html("https://www.youtube.com/results?search_query=dropshipping");
  
  
  $videos = [];
  $i = 1;
  foreach($html -&gt;find("div.yt-lockup yt-lockup-tile yt-lockup-video vve-check clearfix") as $video){
  
        if($i &gt; 10){
          break;
        }
  
        $videoDetails = $video0-&gt;find("a.yt-uix-tile-link yt-ui-ellipsis yt-ui-ellipsis-2 yt-uix-servicelink spf-link");
        $videoTitle = $videoDetails -&gt;title;
        $videoUrl = "http://youtube.com" . $videoDetails-&gt;href;
     echo $videoUrl;
  
       $videos[] = [
  
      "title" =&gt; $videoTitle,
      "link" =&gt; $videoUrl
  
  
        ];
        $i++;
  
  }
  
       echo(sizeof($videos));
  
  ?&gt;
  </code></pre>
  
  <p>This keeps outputting zero(0).
  Can't figure out why this is. I suspect that the  tag link changes every now and then coz i echoed the html page and analyzed the link, some times you'd have the link class to be "yt-uix-servicelink" other times it would be "yt-uix-sessionlink"</p>