title: How to get page content using cURL?
body: <p>I would like to scrape the content of this <a href="https://www.google.com/search?hl=en&amp;tbo=d&amp;tbs=simg:CAESYxphCxCo1NgEGgQIBQgIDAsQsIynCBo4CjYIARIQ-QSMBeUEigSFBYwEiQWABRog8pwYCTxktmeGRsfQir52lJaebNtk-HopuZePSqpeh0gMCxCOrv4IGgoKCAgBEgSh_1cVaDA&amp;q=flower%20&amp;tbm=isch&amp;sa=X&amp;ei=7TsjUZnWNu3smAWDqIHQAg&amp;ved=0CDsQsw4" rel="noreferrer">Google search result page</a> using curl.
  I've been trying setting different user agents, and setting other options but I just can't seem to get the content of that page, as I often get redirected or I get a "page moved" error.</p>
  
  <p>I believe it has something to do with the fact that the query string gets encoded somewhere but I'm really not sure how to get around that.</p>
  
  <pre><code>    //$url is the same as the link above
      $ch = curl_init();
      $user_agent='Mozilla/5.0 (Windows NT 6.1; rv:8.0) Gecko/20100101 Firefox/8.0'
      curl_setopt ($ch, CURLOPT_URL, $url);
      curl_setopt ($ch, CURLOPT_USERAGENT, $user_agent);
      curl_setopt ($ch, CURLOPT_HEADER, 0);
      curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
      curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt ($ch,CURLOPT_CONNECTTIMEOUT,120);
      curl_setopt ($ch,CURLOPT_TIMEOUT,120);
      curl_setopt ($ch,CURLOPT_MAXREDIRS,10);
      curl_setopt ($ch,CURLOPT_COOKIEFILE,"cookie.txt");
      curl_setopt ($ch,CURLOPT_COOKIEJAR,"cookie.txt");
      echo curl_exec ($ch);
  </code></pre>
  
  <p>What do I need to do to get my php code to show the exact content of the page as I would see it on my browser? What am I missing? Can anyone point me to the right direction?</p>
  
  <p>I've seen similar questions on SO, but none with an answer that could help me.</p>
  
  <p>EDIT:</p>
  
  <p>I tried to just open the link using the Selenium WebDriver, that gives the same results as cURL. I am still thinking that this has to do with the fact that there are special characters in the query string which are getting messed up somewhere in the process.</p>