salman_ahad@yahoo.com Posted October 22, 2009 Share Posted October 22, 2009 I need to know the first news heading on news.yahoo.com I need PHP code or script in my webpage which grabs words from Yahoo. Any CODE SNIPPET PLEASE Quote Link to comment Share on other sites More sharing options...
mrMarcus Posted October 22, 2009 Share Posted October 22, 2009 i'm pretty sure Yahoo offers an API with access to their news headlines .. look for "Yahoo News API" or something along those lines. otherwise, you'd be screen-scraping, and it wouldn't be nearly as efficient. Quote Link to comment Share on other sites More sharing options...
salman_ahad@yahoo.com Posted October 22, 2009 Author Share Posted October 22, 2009 I am able to grab text with this code <?php $urlpage = 'http://xyz.com/'; $filetext = fopen("$urlpage", "r"); while (!feof($filetext)) { $theline = fgetss($filetext, 2048); echo "$theline<br>"; } fclose($filetext); ?> How do I grab some specific words, I don't need everything. Quote Link to comment Share on other sites More sharing options...
mrMarcus Posted October 22, 2009 Share Posted October 22, 2009 i don't doubt that it can be done, it's called screen-scraping .. however, i was just suggesting a more efficient (possibly legal) way of accessing Yahoo's data, via their API. you could use preg_match()/preg_match_all(), or if you have an array full of words you want to match, you could use in_array() .. of course there's more involved that just that, but i'm not going to just write you a full script now, am i. what is it you are trying to do exactly with the content you are grabbing, anyways? 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.