Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 437715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T20:36:21+00:00 2026-05-12T20:36:21+00:00

I have a PHP page that I run every minute through a CRON job.

  • 0

I have a PHP page that I run every minute through a CRON job.

I have been running it for quite some time but suddenly it started throwing up these errors:

Maximum execution time of 30 seconds exceeded in /home2/sharingi/public_html/scrape/functions.php on line 84

The line number will vary with each error, ranging from line 70 up into the 90s.

Here is the code from lines 0-95

function crawl_page( $base_url, $target_url, $userAgent, $links)
{
    $ch = curl_init();

    curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
    curl_setopt($ch, CURLOPT_URL,$target_url);
    curl_setopt($ch, CURLOPT_FAILONERROR, false);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_AUTOREFERER, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
    curl_setopt($ch, CURLOPT_TIMEOUT, 100);
    curl_setopt($ch, CURLOPT_MAXREDIRS, 10); //follow up to 10 redirections - avoids loops

    $html = curl_exec($ch);

    if (!$html) 
    {
        echo "<br />cURL error number:" .curl_errno($ch);
        echo "<br />cURL error:" . curl_error($ch);
        //exit;
    }

    //
    // load scrapped data into the DOM
    //

    $dom = new DOMDocument();
    @$dom->loadHTML($html);

    //
    // get only LINKS from the DOM with XPath
    //

    $xpath = new DOMXPath($dom);
    $hrefs = $xpath->evaluate("/html/body//a");

    //
    // go through all the links and store to db or whatever
    //  

    for ($i = 0; $i < $hrefs->length; $i++) 
    {
        $href = $hrefs->item($i);
        $url = $href->getAttribute('href');

        //if the $url does not contain the web site base address: http://www.thesite.com/ then add it onto the front

        $clean_link = clean_url( $base_url, $url, $target_url);
        $clean_link = str_replace( "http://" , "" , $clean_link);
        $clean_link = str_replace( "//" , "/" , $clean_link);

        $links[] = $clean_link;

        //removes empty array values

        foreach($links as $key => $value) 
        { 
            if($value == "") 
            { 
                unset($links[$key]); 
            } 
        } 
        $links = array_values($links); 

        //removes javascript lines

        foreach ($links as $key => $value)
        {
            if ( strpos( $value , "javascript:") !== FALSE )
            {
                unset($links[$key]);
            }
        }
        $links = array_values($links);

        // removes @ lines (email)

        foreach ($links as $key => $value)
        {
            if ( strpos( $value , "@") !== FALSE || strpos( $value, 'mailto:') !== FALSE)
            {
                unset($links[$key]);
            }
        }
        $links = array_values($links);
    }   

    return $links; 
}

What is causing these errors, and how can I prevent them?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T20:36:22+00:00Added an answer on May 12, 2026 at 8:36 pm

    You should set the max_execution time using the set_time_limit function. If you want infinite time (most likely your case), use:

    set_time_limit(0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a php page that displays rows from a mysql db as a
I have a particular PHP page that, for various reasons, needs to save ~200
I have a page that is accessed via a URL like this: http://power-coder.net/Test/something.php?id=3#Page1 I
I'd like to have a page in php that normally displays information based on
I have a PHP-generated page which is displaying some data about a set of
Assuming I'm a big Unix rookie: I'm running a curl request through cron every
I have a web page that displays dynamic data which changes every 2 seconds.
So i have this class that includes some custom functions named class.php I have
I have a site with URLs like this: http://domain.co.uk/subdir/page.php I have redesigned the site
How do I pass have a Javascript script request a PHP page and pass

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.