I'm a rookie programmer, trying to find his footing in PHP and i currently want to build a You-tube scraper.
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.
so far this is what i got:
require('simple_html_dom.php');
$html = file_get_html("https://www.youtube.com/results?search_query=dropshipping");
$videos = [];
$i = 1;
foreach($html ->find("div.yt-lockup yt-lockup-tile yt-lockup-video vve-check clearfix") as $video){
if($i > 10){
break;
}
$videoDetails = $video0->find("a.yt-uix-tile-link yt-ui-ellipsis yt-ui-ellipsis-2 yt-uix-servicelink spf-link");
$videoTitle = $videoDetails ->title;
$videoUrl = "http://youtube.com" . $videoDetails->href;
echo $videoUrl;
$videos[] = [
"title" => $videoTitle,
"link" => $videoUrl
];
$i++;
}
echo(sizeof($videos));
?>
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"