file($url) problem - fulling server into thinking you're a web browser

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Leester

    #1

    file($url) problem - fulling server into thinking you're a web browser

    Hi there,

    I want to try and grab the HTML of a web page, but I have a little
    problem - the web designer/developer of the page! He made it one of
    those pages that displays "Please update your browser. This web site
    does not support Netscape Naivagator version 1.234" if it "thinks"
    your browser isn't up to par.

    When I try to use PHP file($URL) function to grab the HTML, my request
    doesn't have any header information informing the server what my web
    browser is, so I get this message:

    Is there any way to fool it my providing bogus meta/header information
    in my request? Is there another solution?

    Anyone have any ideas? Thanks in advance.

    - Best regards,
    Lee
  • Nikolai Chuvakhin

    #2
    Re: file($url) problem - fulling server into thinking you're a web browser

    lreilly@lanl.go v (Leester) wrote in message
    news:<54b56124. 0312141628.156c 5397@posting.go ogle.com>...[color=blue]
    >
    > Is there any way to fool it my providing bogus meta/header information
    > in my request?[/color]

    Yes. More than one, actually. You can either use cURL:



    or try a homebrewed solution:

    $host = 'www.yourhost.c om';
    $path = 'path/page.htm';
    $fp = fsockopen ($host, '80');
    if ($fp) {
    fputs($fp, 'GET '.$path." HTTP/1.0\r\nHost: ".$host."\r\n") ;
    fputs($fp, "User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows
    NT 5.0)\r\n");
    } else {
    die ('Oops... Nobody home...');
    }
    $data = '';
    while (!feof ($fp)) {
    $data .= fgets ($fp, 10240);
    }
    fclose ($fp);

    Cheers,
    NC

    Comment

    Working...