Hey guys, Need some PHP help here. What I'm trying to do is grab a piece of text/code from youtube page source with PHP. Example: http://www.youtube.com/watch?v=f-rqN0oUEXY If you view the page source of that video above and find the text " "t": " -- what I'm trying to do is grab that value of "t" (FYI this value always change everytime you refresh) with PHP coding. Any help will be greatly appreciated. Green rep and I can even send some cash to anyone who can help me out here. Thanks!
look into fsockopen/fopen/curl/file_get_contents (<- this is the easiest solution) and then preg_match or maybe strpos to get the value
Can you share which route you went with? I love to see this type of thing in action using different techniques.
Here is the code I used: //We include the snoopy class because cant use file_get_contents //on my server. include('snoopy_class.php'); $snoopy = new Snoopy; //URL of the youtube page I want to grab the t value from. You can //put this into a form instead $url = 'http://www.youtube.com/watch?v=f-rqN0oUEXY'; //We fetch the page above from the url variable then put it into //a string variable $snoopy->fetch($url); $url_content = $snoopy->results; //We now find a match within the string from the url above. Then //assign to a variable and echo the value. preg_match('#"t":[\s]?"(.*?)"#i',$url_content,$url_string); $t_string = trim($url_string[1]); echo $t_string; PHP: You can see the script in action here: http://www.mlfscout.com/test.php