selenin Posted May 26, 2010 Share Posted May 26, 2010 Hello, the ultra beginner is back and I try to write a little grabber, that's what I did <? $url = "http://www.novamov.com/search.php?q=Alice+in+wonderland&submit="; $data = file_get_contents($url); $searchterm = 'Alice in Wonderland'; preg_match_all('/<a href[^>]*>'.$searchterm.'/i', $data, $match); var_dump($match); ?> and that's what I got source code: array(1) { [0]=> array(6) { [0]=> string(72) "<a href="http://www.novamov.com/video/dfre8qs9n4yas">Alice in Wonderland" [1]=> string(72) "<a href="http://www.novamov.com/video/4bf1ddd90a2c1">Alice in Wonderland" [2]=> string(72) "<a href="http://www.novamov.com/video/5sixh4i7ip226">Alice in Wonderland" [3]=> string(72) "<a href="http://www.novamov.com/video/4beddd60cba4e">Alice in wonderland" [4]=> string(72) "<a href="http://www.novamov.com/video/dqktchzlsikpa">Alice In Wonderland" [5]=> string(72) "<a href="http://www.novamov.com/video/mnzf1w7pp5lnf">Alice In Wonderland" } } I'm pretty new with arrays, but it looks like a double array and I just wanted to have the urls, no idea what to make with... Link to comment https://forums.phpfreaks.com/topic/203031-my-little-grabber/ Share on other sites More sharing options...
Andy-H Posted May 26, 2010 Share Posted May 26, 2010 <?php $url = "http://www.novamov.com/search.php?q=Alice+in+wonderland&submit="; $data = file_get_contents($url); $searchterm = 'Alice in Wonderland'; preg_match_all('/<a href[^>]*>'.$searchterm.'/i', $data, $match); $urls = array(); foreach($match[0] as $link) { $link = explode('"', $link); $urls[] = $link[1]; } echo '<pre>' . print_r($urls, true) . '</pre>'; ?> Link to comment https://forums.phpfreaks.com/topic/203031-my-little-grabber/#findComment-1063867 Share on other sites More sharing options...
selenin Posted May 27, 2010 Author Share Posted May 27, 2010 wow, thanks a lot, looks like a miracle for me Link to comment https://forums.phpfreaks.com/topic/203031-my-little-grabber/#findComment-1063871 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.