mikey.rr Posted October 20, 2007 Share Posted October 20, 2007 Well, I was thinking about making a news script. Sort of like a CMS, but it will just see data from an RSS feed, go to the link, and rip the news text and title off the page and display it. I don't know if this is even possible. My example: Use MagPieRSS to display CNN's Top Stories RSS (link) If there's an update to the RSS, *somehow* it will get data from the CNN News page (news text, and the title) and display it in a page like "cnn.php?article_id=1". Is this even possible? Or do you have a suggestion about a better way to do this? If I'm not clear, just say so and I'll try to clarify. Oh and by the way, I'd consider myself an intermediate-advanced coder. Quote Link to comment https://forums.phpfreaks.com/topic/74033-question/ Share on other sites More sharing options...
Ninjakreborn Posted October 20, 2007 Share Posted October 20, 2007 I HATE xml parsing. If you want the easy way I suggest searching up (xml to array) class or (xml to html) class. These are going to be your most likely, and easiest, path to take. Or you can parse them from scratch using expat, simple xml, or xml dom (all can be found in rich examples and explanations at www.w3schools.com under the php tutorials. Quote Link to comment https://forums.phpfreaks.com/topic/74033-question/#findComment-373751 Share on other sites More sharing options...
mikey.rr Posted October 20, 2007 Author Share Posted October 20, 2007 that wasn't really what I was looking for...i want to take the text from the link within the rss go to that link i posted, it has a bunch of links to CNN sites. i want to take data from THAT site Quote Link to comment https://forums.phpfreaks.com/topic/74033-question/#findComment-373755 Share on other sites More sharing options...
Ninjakreborn Posted October 20, 2007 Share Posted October 20, 2007 Google "php data harvesting" "php data mining" and "data mining" Quote Link to comment https://forums.phpfreaks.com/topic/74033-question/#findComment-373756 Share on other sites More sharing options...
zq29 Posted October 20, 2007 Share Posted October 20, 2007 You could do something like this: <?php $h = fopen("http://somewhere","r"); $c = stream_get_contents($h); fclose($h); //... //Run some RegEx on $c to pull out the bits you want... //... echo $c; ?> Quote Link to comment https://forums.phpfreaks.com/topic/74033-question/#findComment-373829 Share on other sites More sharing options...
mikey.rr Posted October 20, 2007 Author Share Posted October 20, 2007 Fatal error: Call to undefined function: stream_get_contents() in public_html/mikey/news/cnn2.php on line 3 ?? This is my code: <?php $h = fopen("http://www.cnn.com","r"); $c = stream_get_contents($h); fclose($h); //... //Run some RegEx on $c to pull out the bits you want... //... echo $c; ?> Quote Link to comment https://forums.phpfreaks.com/topic/74033-question/#findComment-373912 Share on other sites More sharing options...
BlueSkyIS Posted October 20, 2007 Share Posted October 20, 2007 stream_get_contents is supported in PHP 5. you're probably on 4. Quote Link to comment https://forums.phpfreaks.com/topic/74033-question/#findComment-373921 Share on other sites More sharing options...
mikey.rr Posted October 20, 2007 Author Share Posted October 20, 2007 Ugh. I tried it on my FreeHostia account which has php 5..but i got this error: Warning: fopen(http://google.com) [function.fopen]: failed to open stream: No route to host in /home/www/gdsweather.freehostia.com/cnn2.php on line 2 Which lead to more errors. Quote Link to comment https://forums.phpfreaks.com/topic/74033-question/#findComment-373928 Share on other sites More sharing options...
Ninjakreborn Posted October 20, 2007 Share Posted October 20, 2007 You can use file_get_contents instead. Quote Link to comment https://forums.phpfreaks.com/topic/74033-question/#findComment-373930 Share on other sites More sharing options...
Ninjakreborn Posted October 20, 2007 Share Posted October 20, 2007 It's because the urlfopen in the ini file is disabled. Change that if possible and it'll work. Quote Link to comment https://forums.phpfreaks.com/topic/74033-question/#findComment-373931 Share on other sites More sharing options...
mikey.rr Posted October 20, 2007 Author Share Posted October 20, 2007 I did phpinfo(); and it says the path to my php.ini file is '/usr/local/Zend/etc/php.ini' but i went into cPanel and under file manager there is no /usr folder.... Quote Link to comment https://forums.phpfreaks.com/topic/74033-question/#findComment-373944 Share on other sites More sharing options...
Ninjakreborn Posted October 20, 2007 Share Posted October 20, 2007 That is then because they are restricting access to it. Try adding a php.ini file in the root directory and set allow urlfopen to on. Then see if it works, if it's ignoring it then it doesn't. Then try htaccess and try setting a flag for url fopen (if there's a flag to it). If that doesn't work contact your host and check your options. Quote Link to comment https://forums.phpfreaks.com/topic/74033-question/#findComment-373945 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.