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 7515221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:44:12+00:00 2026-05-30T00:44:12+00:00

I had an app called GrabUrTime, it’s a timetable viewing utility that get its

  • 0

I had an app called GrabUrTime, it’s a timetable viewing utility that get its timetables from another site, my university’s webspace. Every 2am I run a script that scrapes all the timetables using the parser and dump it into my database.

But today the uni’s server isn’t running well and my script keeps on giving me error 500 on uni’s server, making the script cannot continue to run. It’s periodic, not always. However I tried a few times and it just occurs randomly, no pattern at all.

Hence I want to make my script to handle the error and make it loop until it gets the data.

function grabtable($intakecode, $week) {
$html = file_get_html("http://webspace.apiit.edu.my/schedule/intakeview_intake.jsp?Intake1=".$intakecode."&Week=" . $week);
$dumb = $html->find('table[border=1] tr');
$thatarray = array();
        for ($i=1; $i < sizeof($dumb);++$i){
        $arow = $html->find('table[border=1] tr', $i);
         $date = $arow->find('td font', 0)->innertext;
         $time = $arow->find('td font', 1)->innertext;
        $room = $arow->find('td font', 2)->innertext;
        $loca = $arow->find('td font', 3)->innertext;
         $modu = $arow->find('td font', 4)->innertext;
         $lect = $arow->find('td font', 5)->innertext;
        $anarray = array($date, $time, $room, $loca, $modu, $lect);
        $thatarray[$i] = $anarray;

        //echo "arraylol";
    }
    //echo serialize($tablearray)."<br/>";
    $html->clear();
    return $thatarray;
}
  • 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-30T00:44:13+00:00Added an answer on May 30, 2026 at 12:44 am

    try something like this:

    function getHttpCode($url)
    {
        $agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
        $ch=curl_init();
        curl_setopt ($ch, CURLOPT_URL,$url );
        curl_setopt($ch, CURLOPT_USERAGENT, $agent);
        curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt ($ch,CURLOPT_VERBOSE,false);
        curl_setopt($ch, CURLOPT_TIMEOUT, 5);
        $page=curl_exec($ch);
    
        //echo curl_error($ch);
        $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        curl_close($ch);
    
        if($httpcode>=200 && $httpcode<300) 
        {
            // YOUR CODE
        }
    else
    {
        // What you want to do should it fail
        // perhaps this will serve you better as while loop, e.g.
        // while($httpcode>=200 && $httpcode<300) { ... }
    }
    

    usage

     getHttpCode($url);
    

    It might not plug neatly into your code as it is but I’m sure it can help with a little re-factoring to suit your existing code structure.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created a Django app that had its own internal voting system and a
In my Win32 app, I had a modal dialog that displays settings that I
I had this route in my Rails 2.x app map.with_options(:controller => web_page) do |site|
I had a class called ReportsViewController in my iPhone app. I wanted to restore
I recently had an app rejected because it called a private API - 'hideKeyboard'.
We use ADP for employee information. I had to create a small app that
I had created a small app such that the image which is displaying should
I had a Ruby on Rails app that used to work. I hadn't used
I had written an app for iPhone 3. The app calls safari and while
I had a RoR app working fun under Fedora14, I upgraded to Fedora16 and

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.