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 Quote Link to comment 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> Quote Link to comment 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 } Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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 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.