title: Using boost asio to get web page
body: <p>I'm trying to build a program that would take in a stock ticker, run a google search for it, and output data (current price, high, low, percent change, etc.). I am trying to use boost asio and it is not returning any data from the server.</p>
  
  
  
  <pre><code>#include "stdafx.h"
  #include &lt;iostream&gt;
  #include &lt;istream&gt;
  #include &lt;ostream&gt;
  #include &lt;string&gt;
  #include &lt;boost/asio.hpp&gt;
  
  std::string getStockPage(std::string ticker) {
      boost::asio::ip::tcp::iostream stream;
  
      stream.connect("www.google.com", "http");
      std::cout &lt;&lt; "connected\n";
      stream &lt;&lt; "GET /search?q=" &lt;&lt; ticker &lt;&lt; " HTTP/1.1\r\n";
      stream &lt;&lt; "Host: www.google.com\r\n";
      stream &lt;&lt; "Cache-Control: no-cache\r\n";
      //stream &lt;&lt; "Content-Type: application/x-www-form-urlencoded\r\n\r\n";
      stream &lt;&lt; "Connection: close\r\n\r\n";
      std::cout &lt;&lt; "sent\n";
  
      std::ostringstream os;
      //os &lt;&lt; stream.rdbuf();
      char buffer[100];
      os &lt;&lt; stream.readsome(buffer, 100);
      return std::string(buffer, 100);
  }
  
  int main() {
      std::cout &lt;&lt; getStockPage("$tsla");
      std::cout &lt;&lt; "done\n";
      std::string temp;
      std::getline(std::cin, temp);
      return 0;
  
  
  }
  </code></pre>
  
  <p>
  I tried to read just the first 100 characters to see if it was having issues outputting the response, but it only outputs null characters. I want it to output the entirety of the google page "www.google.com/search?q=$tsla"</p>
  
  <p>Any help would be greatly appreciated!
  </p>