Youtube url scraping

I am trying to build a spider that will go to youtube and cache video page links. I need a regex or simililar that will decide whether a link is for a video page or not. You know, urls like:

Heck, even if you have something already that I can study and tear apart, that would be cool too. Learning is half the fun!

Who is Participating?
dr_dedoConnect With a Mentor Commented:
try this, it will return only valid video links
$html = file_get_contents($url);
$preg = '/<a href="\/watch\?v=(.*?)">.*?<\/a>/';
preg_match_all($preg,$html,$results, PREG_SET_ORDER );

Open in new window

phpintheusaAuthor Commented:
Thank you, you both gave good info for me to learn from! The Dr gets the most because he coded exactly what I needed to see. Thank you both!!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.