Howdy.
First time poster, newbie coder. I've scanned the forums for the last couple hours and although there are some close answers - nothing works nor accomplishes my job.
My goal:
Scrape a website, find all youtube links, create a page with all videos found via iframe.
My Issue: My code below works great, but all the URLS look like http://www.youtube.com/watch?v=xxxxxxxxxxx
Not sure what to do. Should I use str_replace to change it from that to http://www.youtube.com/embed/xxxxxxxx ?
Here's the code:
<?php
$curl = curl_init();
curl_setopt ($curl, CURLOPT_URL, "http://xxxxx");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec ($curl);
curl_close ($curl);
//links
if(preg_match_all("/(http\:\/\/www\.youtube\.com\/watch\?v=\w{11})/", $result, $links))
{
foreach($links[0] as $link)
{
echo $link."<br />";
}
}
?>
Thanks!