Getting page with fopen - PHP

This is a discussion on Getting page with fopen - PHP ; Hello! I'm trying to find out on which rank my side is at google automatically. I'm trying the following code, but I get a strange error: $Url = "http://www.google.de/search?q=MySearchWord"; // Gives "Warning: No error on line [where fopen is]" $Url ...

+ Reply to Thread
Results 1 to 5 of 5

Getting page with fopen

  1. Default Getting page with fopen

    Hello!

    I'm trying to find out on which rank my side is at google automatically.
    I'm trying the following code, but I get a strange error:

    $Url = "http://www.google.de/search?q=MySearchWord"; // Gives "Warning:
    No error on line [where fopen is]"
    $Url = "http://www.google.de/"; // Works

    for ($i = 0; $i < 100; $i += 10)
    { $fp = fopen($Url, "r");
    while($fp && !feof($fp))
    { $sLine .= fgets($fp, 4096);
    }
    ... do some further things with $sLine
    fclose($fp);
    }

    How can I get more information about the error occuring? "Warning: No
    error" is not much information...

    Martin




  2. Default Re: [PHP] Getting page with fopen

    On Thursday 25 April 2002 16:39, Martin Thoma wrote:
    > Hello!
    >
    > I'm trying to find out on which rank my side is at google automatically.
    > I'm trying the following code, but I get a strange error:
    >
    > $Url = "http://www.google.de/search?q=MySearchWord"; // Gives "Warning:
    > No error on line [where fopen is]"
    > $Url = "http://www.google.de/"; // Works
    >
    > for ($i = 0; $i < 100; $i += 10)
    > { $fp = fopen($Url, "r");
    > while($fp && !feof($fp))
    > { $sLine .= fgets($fp, 4096);
    > }
    > ... do some further things with $sLine
    > fclose($fp);
    > }
    >
    > How can I get more information about the error occuring? "Warning: No
    > error" is not much information...


    Google is probably trying to send you a cookie in which case you cannot use
    fopen. You need to use curl or snoopy(?).

    --
    Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
    Open Source Software Systems Integrators
    * Web Design & Hosting * Internet & Intranet Applications Development *

    /*
    When the wind is great, bow before it;
    when the wind is heavy, yield to it.
    */

  3. Default Re: [PHP] Getting page with fopen

    > Google is probably trying to send you a cookie in which case you cannot use
    > fopen. You need to use curl or snoopy(?).


    Thanx, that could be the problem. Unfortunatly, curl is not compiled in my
    php-version, and what is snoopy?! ;-) Any other ideas/examples?

    Martin





  4. Default Re: [PHP] Solved Getting page with fopen

    Ah, it works with fsockopen:

    $fp = fsockopen ("www.google.com", 80, $errno, $errstr, 30);
    if (!$fp)
    { print "Fehler: $errstr ($errno)\n";
    }
    else
    { fputs ($fp, "GET / HTTP/1.0\r\nHost: $Url\r\n\r\n");
    while (!feof($fp))
    { $sLine .= fgets ($fp, 4096);
    }
    }
    fclose ($fp);



  5. Default Re: [PHP] Getting page with fopen

    At 25.04.2002 11:01, you wrote:
    >
    > > Google is probably trying to send you a cookie in which case you cannot use
    > > fopen. You need to use curl or snoopy(?).

    >
    >Thanx, that could be the problem. Unfortunatly, curl is not compiled in my
    >php-version, and what is snoopy?! ;-) Any other ideas/examples?
    >
    >Martin

    snoopy is a class which lets you fetch pages from the web, like you want to do.
    It supports cookies,https and some other stuff useful for fetching pages
    from the
    web. Look at sourceforge to get the latest release. This is one of my
    favours ;-)
    Oliver


+ Reply to Thread