title: JavaScript HTTP GET
body: <p>I have a questions about HTTP GET request made in Javascript: </p>
  
  <p>1) How can this be done? </p>
  
  <p>2) Can this be done like curl in php? I mean that i can get any webpage and parse its content and retrieve some info based on Regular expression? </p>
  
  <p>3) Is such Http request made from server Ip address or client side Ip address? </p>
  
  <pre><code>private function getWebPage($url)
              {
  
                  $options = array(
                      CURLOPT_RETURNTRANSFER =&gt; true,     // return web page
                      CURLOPT_HEADER         =&gt; false,    // don't return headers
                      CURLOPT_FOLLOWLOCATION =&gt; true,     // follow redirects
                      CURLOPT_ENCODING       =&gt; "",       // handle all encodings
                      CURLOPT_USERAGENT      =&gt; "spider", // who am i
                      CURLOPT_AUTOREFERER    =&gt; true,     // set referer on redirect
                      CURLOPT_CONNECTTIMEOUT =&gt; 120,      // timeout on connect
                      CURLOPT_TIMEOUT        =&gt; 120,      // timeout on response
                      CURLOPT_MAXREDIRS      =&gt; 10,       // stop after 10 redirects
                  );
  
                  $ch      = curl_init( $url );
                  curl_setopt_array( $ch, $options );
                  $content = curl_exec( $ch );
                  $err     = curl_errno( $ch );
                  $errmsg  = curl_error( $ch );
                  $header  = curl_getinfo( $ch );
                  curl_close( $ch );
  
                  $header['errno']   = $err;
                  $header['errmsg']  = $errmsg;
                  $header['content'] = $content;
                  return $content;
              } 
  </code></pre>