Обратный Аякс (код включен) - PullRequest
0 голосов
/ 13 июня 2011

Я пытаюсь собрать поток цен в реальном времени от Google Finance (для ftse, но я не особо обеспокоен, какой инструмент). Я хочу попробовать передать данные на веб-страницу.

Я нашел этот пример на веб-сайте MSDN, но после изменения свойства keep alive на 'true' поток не работает .....

Я нашел URL с помощью firefox и firebug, он отправлял запросы GET на страницу

  // Create a new HttpWebRequest object.Make sure that 
  // a default proxy is set if you are behind a firewall.
  HttpWebRequest myHttpWebRequest1 =
    (HttpWebRequest)WebRequest.Create("http://www.google.com/finance/getprices?q=UKX&x=INDEXFTSE&i=120&p=25m&f=d,c,v,o,h,l&df=cpct&auto=1&ts=1307957334498");

  myHttpWebRequest1.KeepAlive=true;
  // Assign the response object of HttpWebRequest to a HttpWebResponse variable.
  HttpWebResponse myHttpWebResponse1 = 
    (HttpWebResponse)myHttpWebRequest1.GetResponse();

  Console.WriteLine("\nThe HTTP request Headers for the first request are: \n{0}",myHttpWebRequest1.Headers);
  Console.WriteLine("Press Enter Key to Continue..........");
  Console.Read();

  Stream streamResponse=myHttpWebResponse1.GetResponseStream();
  StreamReader streamRead = new StreamReader( streamResponse );
  Char[] readBuff = new Char[256];
  int count = streamRead.Read( readBuff, 0, 256 );
  Console.WriteLine("The contents of the Html page are.......\n");  
  while (count > 0) 
  {
    String outputData = new String(readBuff, 0, count);
    Console.Write(outputData);
    count = streamRead.Read(readBuff, 0, 256);
  }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...