Http Status Code 0 - Please Help

Discussion in 'PHP' started by parallelsruler, Dec 19, 2010.

  1. #1
    Hi All,

    Recently I wrote a php script for checking the http return status code of webpages. The script will accept a url, get its source code, parse it to find out the child urls and check the status codes of these child urls. I am using cUrl and DomDocument for this.

    But i noticed that while checking some pages it is returning status code of '0' for some of the child urls. I know that 0 is not a valid status code and this might be a problem with headers. Please let me know if there is any possibility of overcoming this.

    Thanks in advance. Have a nice day!
     
    parallelsruler, Dec 19, 2010 IP
  2. tvoodoo

    tvoodoo Active Member

    Messages:
    239
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    53
    #2
    If you would paste your code then we might be able to help you...
     
    tvoodoo, Dec 19, 2010 IP
  3. parallelsruler

    parallelsruler Peon

    Messages:
    80
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Part of the code, that i am using for checking the status code, is given below

    $url = 'http://example.com/';
    $ch = curl_init();
    curl_setopt ($ch, CURLOPT_URL,$url);
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
    $page=curl_exec($ch);
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);
     
    parallelsruler, Dec 19, 2010 IP
  4. tvoodoo

    tvoodoo Active Member

    Messages:
    239
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    53
  5. parallelsruler

    parallelsruler Peon

    Messages:
    80
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Sorry folks, it is my mistake only. When i parsed the source code for child urls, i was getting relative paths and this caused the response code to be '0'.

    Now I would have convert it into absolute url and hopefully this will correct the error. Can you please help me with this.
     
    parallelsruler, Dec 19, 2010 IP