dingus Posted March 13, 2008 Share Posted March 13, 2008 hi im writeing a script atm and it needs to pull the catagory from youtube videos <div> <span class="smallLabel">Category: </span> <a href="/browse?s=mp&t=t&c=23" class="dg smallText" onclick="_hbLink('VideoCategoryLink','Watch3VideoDetails');">Comedy</a> </div> that block there i have been trying several things but i cant seem to come to a solution how would i extract the word extract the word in read from said page? but it would need to be extracted ignoreing the accual word AND the part in blue i hope there is some one who can help me Link to comment https://forums.phpfreaks.com/topic/95897-extract-data-from-website/ Share on other sites More sharing options...
effigy Posted March 13, 2008 Share Posted March 13, 2008 <pre> <?php $data = <<<DATA <div> <span class="smallLabel">Category: </span> <a href="/browse?s=mp&t=t&c=23" class="dg smallText" onclick="_hbLink('VideoCategoryLink','Watch3VideoDetails');">Comedy</a> </div> DATA; preg_match('/Category.+?<a[^>]+>([^<]+)/s', $data, $matches); echo $matches[1]; ?> </pre> Link to comment https://forums.phpfreaks.com/topic/95897-extract-data-from-website/#findComment-491262 Share on other sites More sharing options...
discomatt Posted March 13, 2008 Share Posted March 13, 2008 $subject = <<<EOF <div> <span class="smallLabel">Category: </span> <a href="/browse?s=mp&t=t&c=23" class="dg smallText" onclick="_hbLink('VideoCategoryLink','Watch3VideoDetails');">Comedy</a> </div> EOF; if (preg_match_all('%<a href="(/browse?[^"]+)[^>]+>([^<]+)%i', $subject, $matches)) { print_r($matches); } else { # Match attempt failed } Link to comment https://forums.phpfreaks.com/topic/95897-extract-data-from-website/#findComment-491663 Share on other sites More sharing options...
discomatt Posted March 13, 2008 Share Posted March 13, 2008 That above code extracts teh part in blue and the part in red. I'm not entirely sure if you wanted that or not. Please be more specific and proofread your posts. Link to comment https://forums.phpfreaks.com/topic/95897-extract-data-from-website/#findComment-491665 Share on other sites More sharing options...
dingus Posted March 14, 2008 Author Share Posted March 14, 2008 hey guys exactly what i needed i am really thankful the help and am sorry about the sloppy post after rereading that was really written terribly will try not to let it happen again Link to comment https://forums.phpfreaks.com/topic/95897-extract-data-from-website/#findComment-491840 Share on other sites More sharing options...
effigy Posted March 14, 2008 Share Posted March 14, 2008 hey guys exactly what i needed i am really thankful the help and am sorry about the sloppy post after rereading that was really written terribly will try not to let it happen again Tip: Use more punctuation Link to comment https://forums.phpfreaks.com/topic/95897-extract-data-from-website/#findComment-492211 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.