google click through link

Discussion in 'PHP' started by khatarat, Apr 7, 2010.

  1. #1
    hi
    when in a google result page you click on a link you first go in a link in google and then you will redirect to destination page.
    its because function rwt in onmouse down event.
    i want to get this link with php but when i send http request to google there isnt any onmousedown in response body

    how can i send http request just like a browser to get this link?
     
    khatarat, Apr 7, 2010 IP
  2. krsix

    krsix Peon

    Messages:
    435
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    signed in with a google account, it'll log clicks to webhistory
     
    krsix, Apr 8, 2010 IP
  3. khatarat

    khatarat Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    i tell you with an example
    when u search "php" in google in result page when u click on a result u first will go to a google url and then u redirect to your url like this:
    http://www.google.com/url?sa=t&source=web&ct=res&cd=1&ved=0CAgQFjAA&url=http%3A%2F%2Fphp.net%2F&ei=jq6-S_myMaD00gSBwvmlCQ&usg=AFQjCNFREyspp5CvzVpYmRmTltZQc8ldmQ&sig2=4OOdOpzlboTeCKx4i2K_mQ

    this link count clicks on a page link
    this link has created with java function rwt.
    but this function only when u request a google result page with browser will apear but when i request that page with php this function not exist
    now i want to do like a browser with php to get that link
     
    khatarat, Apr 8, 2010 IP
  4. krsix

    krsix Peon

    Messages:
    435
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #4
    yes. have your script authenticate (be logged into a google account), accept cookies, send cookies on each pageload, and use a browser's user-agent.

    it will give you tracking URLs then.
     
    krsix, Apr 8, 2010 IP
  5. khatarat

    khatarat Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    can u give me a sample code for sending http request like a browser?
     
    khatarat, Apr 9, 2010 IP
  6. krsix

    krsix Peon

    Messages:
    435
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #6
    php.net/curl
     
    krsix, Apr 10, 2010 IP
  7. khatarat

    khatarat Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    i can send a http request but when i send a http request the body of responsed page is diffrent from a result page that google has responded to a browser.
    can u give me the full pattern of a http request include user agent cookies and other things that a browser send to google?
     
    khatarat, Apr 10, 2010 IP
  8. krsix

    krsix Peon

    Messages:
    435
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #8
    set these options: CURLOPT_COOKIEJAR, CURLOPT_USERAGENT

    alternatively, Google may serve content differently if you don't have javascript (search?q=query vs #q=query loads different pages)
     
    krsix, Apr 10, 2010 IP
  9. khatarat

    khatarat Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    i use this code but it didnt work

    $ch= curl_init();
    // set url
    //curl_setopt($ch, CURLOPT_URL, "http://pgl.yoyo.org/http/browser-headers.php");
    curl_setopt($ch, CURLOPT_URL,"http://www.google.com/search?client=opera&rls=en&q=serial&sourceid=opera&ie=utf-8&oe=utf-8");
    //return the transfer as a string
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_USERAGENT, "Opera/9.80 (Windows NT 6.1; U; en) Presto/2.2.15 Version/10.10");
    curl_setopt($ch, CURLOPT_COOKIEJAR, "cookieFileName.txt");

    // $output contains the output string
    $output = curl_exec($ch);

    // close curl resource to free up system resources
    curl_close($ch);
    echo $output;



    when i turn off cookie enable of my opera browser the response body of google is more like the response body of curl code. how can i tell google with curl that my cookie is enabled?
     
    Last edited: Apr 10, 2010
    khatarat, Apr 10, 2010 IP