Unable to open a specific URL

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Steve Mays
    New Member
    • Dec 2010
    • 1

    Unable to open a specific URL

    I can open many urls with php and parse out the info I need, but not the ones on this domain (www.bobmoore.c om). I have tried many different ways of getting into it (fsockopen, curl, ...) with no luck. I normally grab the entire pages contents before parsing them but here is the most simplistic example of what I am trying to do and what the results are.

    This one works with www.google.com
    <?php
    $in_url_stream = fopen("http://www.google.com" , "r");
    if($in_url_stre am == false){
    die("Error Opening URL");
    }
    $buffer = fgets($in_url_s tream, 1000);
    echo $buffer;
    ?>

    Results as expected - a chunk of text:
    <!doctype html><html><hea d><meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"><title>Googl e</title><script>w indow.google={k EI:"i1EKTdHzFZu 88wStmLRG",kEXP I:"27342",kCSI: {e:"27342",ei:" i1EKTdHzFZu88wS tmLRG",expi:"27 342"},ml:functi on(){},kHL:"en" ,time:function( ){return(new Date).getTime() },log:function( a,d,


    But it does not work when I change the url to www.bobmoore.co m
    <?php
    $in_url_stream = fopen("http://www.bobmoore.co m", "r");
    if($in_url_stre am == false){
    die("Error Opening URL");
    }
    $buffer = fgets($in_url_s tream, 1000);
    echo $buffer;
    ?>

    Results:
    <b>Warning</b>: fopen(http://www.bobmoore.co m) [<a href='function. fopen'>function .fopen</a>]: failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error
    in <b>PHPDocument6 </b> on line <b>2</b><br />
    Error Opening URL

    Any help on this would be greatly appreciated.
  • johny10151981
    Top Contributor
    • Jan 2010
    • 1059

    #2
    issue is related with the header

    when you request for
    http://www.bobmoore.co m/
    a redirection request is generated
    The header is like below:
    Code:
    HTTP/1.0 301 Moved Permanently
    Location: http://www.bobmoore.com/index.htm
    Server: BigIP
    Connection: Keep-Alive
    Content-Length: 0
    and new location is set to
    Code:
    http://www.bobmoore.com/index.htm
    try to open
    Code:
    http://www.bobmoore.com/index.htm
    you may get somewhere

    Comment

    Working...