[email protected] 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 Link to comment https://forums.phpfreaks.com/topic/178644-solved-grab-text-from-yahoo/ 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. Link to comment https://forums.phpfreaks.com/topic/178644-solved-grab-text-from-yahoo/#findComment-942293 Share on other sites More sharing options...
[email protected] 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. Link to comment https://forums.phpfreaks.com/topic/178644-solved-grab-text-from-yahoo/#findComment-942340 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? Link to comment https://forums.phpfreaks.com/topic/178644-solved-grab-text-from-yahoo/#findComment-942349 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.