Note that there are some explanatory texts on larger screens.

plurals
  1. POconfigure curl to get www.google.com
    primarykey
    data
    text
    <p>How to get curl response properly using php curl. I tried to change some request header and user agent</p> <pre><code>GET / HTTP/1.1 User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7 Host: www.google.com Accept: */* Accept-Encoding: gzip,deflate,sdch </code></pre> <p>but its not working am getting 302 error</p> <pre><code>HTTP/1.1 302 Found Location: http://www.google.co.in/ Cache-Control: private Content-Type: text/html; charset=UTF-8 Set-Cookie: PREF=ID=30a99703e541807e:FF=0:TM=1324467004:LM=1324467004:S=0VlXyYEJtxKQ_Pqk; expires=Fri, 20-Dec-2013 11:30:04 GMT; path=/; domain=.google.com Date: Wed, 21 Dec 2011 11:30:04 GMT Server: gws Content-Length: 221 X-XSS-Protection: 1; mode=block X-Frame-Options: SAMEORIGIN </code></pre> <p>the html output that i get is </p> <pre><code>&lt;HTML&gt;&lt;HEAD&gt;&lt;meta http-equiv="content-type" content="text/html;charset=utf-8"&gt; &lt;TITLE&gt;302 Moved&lt;/TITLE&gt;&lt;/HEAD&gt;&lt;BODY&gt; &lt;H1&gt;302 Moved&lt;/H1&gt; The document has moved &lt;A HREF="http://www.google.co.in/"&gt;here&lt;/A&gt;. &lt;/BODY&gt;&lt;/HTML&gt; </code></pre> <p>how to get and post data using php curl as if we are doing it from browser. </p> <p>here is my php code for <code>curl_setopt</code></p> <pre><code>curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_USERAGENT, " Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate,sdch'); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload