strago Posted September 10, 2010 Share Posted September 10, 2010 How do you have a script, after getting the page, search for and as the result, post *part* of every link that ends like... &v=ANYTHING">Link text</a> and as the result, posting just ANYTHING">Link text<BR> I'm messing with... <?php $page = $_GET['page']; $user = $_GET['user']; $doc = new DOMDocument; $doc->load('http://m.youtube.com/profile?gl=US&client=mv-google&hl=en&user=$user&view=videos&p=$page'); $items = $doc->getElementsByTagName('a'); foreach($items as $value) { echo $value->nodeValue . "\n"; $attrs = $value->attributes; echo $attrs->getNamedItem('href')->nodeValue . "\n"; }; ?> but it get's way too much stuff. Get's data from every link on the page, and posts it as Page Text /watch?gl=US&client=mv-google&hl=en&v=XXXXX And I can't get $page = $_GET['page']; $user = $_GET['user']; to get the data from the URL. Quote Link to comment Share on other sites More sharing options...
strago Posted September 10, 2010 Author Share Posted September 10, 2010 <?php $page = $_GET['page']; $user = $_GET['user']; $request_url ="http://m.youtube.com/profile?gl=US&client=mv-google&hl=en&user=$user&view=videos&p=$page"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $request_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($ch); //Part of URL to get. videoID">title $regex='|v=(.*?)</a>|'; preg_match_all($regex,$result,$parts); $links=$parts[1]; foreach($links as $link){ echo $link."<br>"; } curl_close($ch); ?> does it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.