EG Information
Training Missions
Knowledge Bank
|
|
Enigma Group's Code Bank
RSS cache scriptBy: Ausome1 - Date Submitted: 2008-09-25 18:59:59 <?php /** * RSS cache script * * Run this script via cron. I run mine every 15 minutes. This will cache rss feeds on your local * machine in /tmp naming the files rss1.cache, rss2.cache and so on. Have your rss reader access * your rss feeds that are locally stored. This will keep you from getting banned to that rss feed * if you're hitting it on every page load and save you and the rss supplier lots of bandwidth. * * This script also uses parallel processing. It will go out and grab the rss feeds all at once. * Lets say you want to gather data from 5 sites and each site takes 5 seconds to scrape. Gathering * each site sequentially would take 25 seconds (5 x 5) for the script to complete. Running the * gathering in parallel allows the script to finish in 5 seconds. The length of the longest scrape. * * @author Ausome1 */ // URLs of content you wish to cache. $urls = array('http://example1.com/rss.xml', 'http://example2.com/rss.xml', 'http://example3.com/rss.xml', 'http://example4.com/rss.xml', 'http://example5.com/rss.xml' ); // No need to alter anything past here. // Create cURL instances, set URL, and other appropriate options. for ($i = 1; $i <= $count; ++$i) { $handle = 'ch' . $i; } // Create the multiple cURL handle. // Add handles for ($i = 1; $i <= $count; ++$i) { $handle = 'ch' . $i; } $running = NULL; { // Retrieve content and write data to cache file. for ($i = 1; $i <= $count; ++$i) { $handle = 'ch' . $i; $data = 'data' . $i; $response_code = 'response_code' . $i; $$response_code = curl_getinfo($$handle, CURLINFO_HTTP_CODE ); if ($$data && $$response_code != '404') { file_put_contents('/tmp/rss' . $i . '.cache', $$data); } } // Close curl session. ?>
|
| Return to
php category list |
|
|
Who's Online
405 Guests, 117 Users c0re, aVoid, qlerner, raven001, N4g4c3N, hettoo, Distorted, Link-, Ops, apablo, hemiptera, Predatorc, Bloodmaster25, sameer kumar, damo, Nasrudin, Rex_Mundi, bakiido, klesco, destroyer, Bago, Psiber_Syn, psychomarine, darkang3l, m4r71an, shane007, glockz, somisettynaresh, lacanian, iwanlearn, cutie117098, Drakelx, jarlskov, Vahakn, buffer, flower, Brave, KingSpawn, avalor, RedEvolution, tkb2999, EngGi235, dark_void, hacker807, noother, omnipresence, blink_212, NotMyOwn, lgee227, Ghostrider, Calumoo, livinbeneath, deskata, lionaneesh, cracker, data, invas10n, LiquidSnake, TheFender, kcaz, T-Metal, ace386, hulk9914, BinaryShinigami, cd365, st3alth, Burning_Hardware, mark63534, Pizza, Lingt, spumoni27, j0sh, KaosFactor, Protagoras, DeKoala, pimpsta5000, computerbp13, Ausome1, enyo, Ultraminor, mm256, Bearmaul, sirEgghead, cracker18, Ashok_thepower, C, Base, chaos-angel, ergo, DnA-Ender, InjectioN, Virgin Mary, xXxAngelBabykxXx, obrigadoo, timmy, ishkur88, TrAnE, forty2, SaMTHG, FatalNIX, totalnoob, figjam, knight_pars, snozzberries, naren211, zofy, tucak, strycnine, TheRetech, chekifr, teehee, Zheka, aloksaini, greatness87, tnhtm, piking, nicks_707 |
| |
|
|
|
|
|