Edmonds Commerce Logo
  • home
    • blog
  • ecommerce
    • product catalogue
    • order processing
    • customer services
    • stock control
    • human resources
    • management information
  • development
    • oscommerce
    • php
    • mysql
    • open source
    • performance tuning
  • design
  • marketing
  • contact us
    • pricing

Edmonds Commerce Blog

Freelance PHP Ecommerce and SEO Developer in the UK

Latest Posts

Securing a LAMP Server with mod_security
osCommerce Easypopulate File Creator Class
CRELoaded Remove Google Ads -
ICECat Integration with osCommerce, Magento etc

Most Popular Posts

PHP Email Attachment Function Freelance osCommerce UK Ultimate osCommerce Checkout - Fast and Friendly PHP : Dead Easy Excel Export

PHP Random Sleep Function with Flush

June 9th, 2008
Read More php, scraping

Sometimes you want your script to pause for a short period of time before repeating a loop or proceeding to the next step. This may be to reduce server load or even to simulate the natural pauses that a person would make whilst browsing a site. This kind of thing is especially true if you are building a system to scrape content such as product information from a suppliers web site and you do not want to hammer their server to death and get your IP banned.

PLAIN TEXT
PHP:
  1. function sleep_flush($chunks=10){
  2.  
  3.     $c=0;
  4.  
  5.     while($c <$chunks){
  6.  
  7.        $rand = rand(2000000, 6000000);
  8.  
  9.        echo '<br> . . . sleeping for ' . round(($rand / 1000000),2) . ' seconds . . . zzzzzzzzzzzzzz<br>';
  10.  
  11.        flush();
  12.  
  13.        usleep($rand);
  14.  
  15.        $c++;
  16.  
  17.     }
  18.  
  19. }

This function will do just that for you. Also it has a built in flush which will help in preventing the script from being regarded as timed out if you are running it from the web browser.

Bookmark this Post
Add 'PHP Random Sleep Function with Flush' to Del.icio.usAdd 'PHP Random Sleep Function with Flush' to diggAdd 'PHP Random Sleep Function with Flush' to FURLAdd 'PHP Random Sleep Function with Flush' to blinklistAdd 'PHP Random Sleep Function with Flush' to redditAdd 'PHP Random Sleep Function with Flush' to Feed Me LinksAdd 'PHP Random Sleep Function with Flush' to TechnoratiAdd 'PHP Random Sleep Function with Flush' to Yahoo My WebAdd 'PHP Random Sleep Function with Flush' to NewsvineAdd 'PHP Random Sleep Function with Flush' to SocializerAdd 'PHP Random Sleep Function with Flush' to Ma.gnoliaAdd 'PHP Random Sleep Function with Flush' to Stumble UponAdd 'PHP Random Sleep Function with Flush' to Google BookmarksAdd 'PHP Random Sleep Function with Flush' to RawSugarAdd 'PHP Random Sleep Function with Flush' to SquidooAdd 'PHP Random Sleep Function with Flush' to SpurlAdd 'PHP Random Sleep Function with Flush' to BlinkBitsAdd 'PHP Random Sleep Function with Flush' to NetvouzAdd 'PHP Random Sleep Function with Flush' to RojoAdd 'PHP Random Sleep Function with Flush' to BlogmarksAdd 'PHP Random Sleep Function with Flush' to ShadowsAdd 'PHP Random Sleep Function with Flush' to Co.mments
Add 'PHP Random Sleep Function with Flush' to ScuttleAdd 'PHP Random Sleep Function with Flush' to BloglinesAdd 'PHP Random Sleep Function with Flush' to TailrankAdd 'PHP Random Sleep Function with Flush' to SegnaloAdd 'PHP Random Sleep Function with Flush' to OKnotizieAdd 'PHP Random Sleep Function with Flush' to NetscapeAdd 'PHP Random Sleep Function with Flush' to Bookmark.itAdd 'PHP Random Sleep Function with Flush' to AskAdd 'PHP Random Sleep Function with Flush' to SmarkingAdd 'PHP Random Sleep Function with Flush' to LinkagogoAdd 'PHP Random Sleep Function with Flush' to DeliriousAdd 'PHP Random Sleep Function with Flush' to SocialdustAdd 'PHP Random Sleep Function with Flush' to Live-MSNAdd 'PHP Random Sleep Function with Flush' to SlashDotAdd 'PHP Random Sleep Function with Flush' to SphinnAdd 'PHP Random Sleep Function with Flush' to DiggitaAdd 'PHP Random Sleep Function with Flush' to SeotribuAdd 'PHP Random Sleep Function with Flush' to FaceBookAdd 'PHP Random Sleep Function with Flush' to UpnewsAdd 'PHP Random Sleep Function with Flush' to WikioAdd 'PHP Random Sleep Function with Flush' to Social Bookmarking Reloaded

Feed | Respond | Trackback

Leave a Reply

  • RSS Feed
  • Categories

    • apache
    • barcode
    • creloaded
    • curl
    • customer services
    • debugging
    • ecommerce
    • email
    • excel
    • firefox
    • flash
    • gd
    • graphs
    • hosting
    • icecat
    • internet news
    • javascript
    • link building
    • linux
    • magento
    • management
    • mod_rewrite
    • mysql
    • oscommerce
    • php
    • plesk
    • product catalogue
    • product feed
    • programming
    • regular expressions
    • scraping
    • search engine optimisation
    • security
    • spidering
    • ubuntu
    • web design
    • web development
    • Windows
    • xampp
    • zip
  • Archives

    • September 2008
    • August 2008
    • July 2008
    • June 2008
    • May 2008
    • April 2008
    • March 2008
    • February 2008
  • Tags

    addons advanced adverts blackhat blocking css curl development directories find firefox google hosts file html javascript keywords links msn mysql myths operators oscommerce paid links paid placement performance php ppc reciprocal linking replace screen scraping security seo serp speed spider spidering tuning user friendly vista web web design web developer
  • Random Posts

    • PHP Random Sleep Function with Flush
    • SEO, Links, Pagrank and Anchor Text
    • Building Spiders: Grab Data, Post Forms and Interact with Web Sites Automatically
    • Web Developer Toolbar for Firefox
    • Freelance osCommerce UK
    • osCommerce Contribution Released: Server Migration Synchronisation
    • Ecommerce Back Office Optimisations
    • osCommerce Password Reset Using phpMyAdmin
    • PHP and Zip Files
    • Handy Easy Javascript

Edmonds Commerce related questions? Send us a message or call us on 0844 357 0201.

Freelance PHP Web Design UK Commercial Web Design