cURL help

Discussion in 'PHP' started by cipcip, Jul 2, 2008.

  1. #1
    I made a pagerank checker, some of you may know it ... anyway I have a problem which I can`t figure it out ...

    The alexa function is this:

    function getAlexaRank () {
                $url = $this->url['host'];
                $url = "http://data.alexa.com/data?cli=10&dat=s&url=$url";
                $data = $this->getPage($url);
                preg_match('#<POPULARITY URL="(.*?)" TEXT="([0-9]+){1,}"/>#si', $data, $p);
                $value = ($p[2]) ? number_format($this->toInt($p[2])) : 0;
                return $value;
            }
    Code (markup):
    This worked about one month and now is not working anymore.

    Now, I used the var_dump(htmlentities($data)) command and it shows me this:

    string(466) "<?xml version="1.0" encoding="UTF-8"?> <ALEXA VER="0.9" URL="alexa.com/" HOME="0" AID="="> <RLS TITLE="Related Links" PREFIX="http://" more ="0"> <RL HREF="xslt.alexa.com/blocker?tag=Ujmccxavvjjajpjvj=0000000000000&amp;ref=data.alexa.com/" TITLE="Please click here to continue using Alexa"/> </RLS> </ALEXA> "
    Code (markup):
    Someone told me that Alexa detects that I want to abuse their service and that is why it is not working anymore.

    The only solution to work is to make a cURL array of proxies ... the only problem is that i never used that because i didn`t need it so far.

    Can someone give me a good starting point ?

    Thank you!
     
    cipcip, Jul 2, 2008 IP
  2. CodyRo

    CodyRo Peon

    Messages:
    365
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #2
    To put it simply - just check the cURL section of the PHP website.

    As for the proxy portion check the curl_setopt() function with the CURLOPT_HTTPPROXYTUNNEL option.

    If you need further help ask :).
     
    CodyRo, Jul 3, 2008 IP
  3. cipcip

    cipcip Well-Known Member

    Messages:
    1,935
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    160
    #3
    Thank you, I will try ...
     
    cipcip, Jul 3, 2008 IP
  4. cipcip

    cipcip Well-Known Member

    Messages:
    1,935
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    160
    #4
    I made a curl syntax ... the only thing is that I don`t know how to integrate it with my current function ...

    This is the code:

    <?php
    $proxyip = array(
     '87.234.234.68:80',
    // '203.178.133.11:3124',
    // '192.38.109.144:3128',
    );
    
    $randp = rand(0, 1);
    
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, true);
    curl_setopt($ch, CURLOPT_PROXY, $proxyip[$randp]);
    curl_setopt($ch, CURLOPT_URL, 'http://data.alexa.com/data?cli=10&dat=s&url=$url');
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_exec($ch);
    curl_close($ch);
    ?>
    Code (markup):
    This is the alexa function:

    function getAlexaRank () {
                $url = $this->url['host'];
                $url = "http://data.alexa.com/data?cli=10&dat=s&url=$url";
                $data = $this->getPage($url);
                preg_match('#<POPULARITY URL="(.*?)" TEXT="([0-9]+){1,}"/>#si', $data, $p);
                $value = ($p[2]) ? number_format($this->toInt($p[2])) : 0;
                return $value;
            }
    Code (markup):
    Can someone please help me ?
     
    cipcip, Jul 3, 2008 IP
  5. cipcip

    cipcip Well-Known Member

    Messages:
    1,935
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    160
    #5
    anyone ? :(
     
    cipcip, Jul 4, 2008 IP
  6. cipcip

    cipcip Well-Known Member

    Messages:
    1,935
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    160
    #6
    doesn`t matter anymore ... i made it!
     
    cipcip, Jul 5, 2008 IP