PC Review


Reply
Thread Tools Rate Thread

Problems with carret in URL (real time ticker sample)

 
 
Mikeerh
Guest
Posts: n/a
 
      15th May 2009
I have a ticker sample running with yahoo as provider.
When it comes to indices they all start with a caret (^) like ^DJI.
The framework converts this string internally into a %% before it is on the
net (I saw it with wireshark) and than yahoo responds with a N/A ??
How can I get the framework to let the carret through??

here is the sample code:

?using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;

namespace YahooTicker
{
class Program
{


private static void Main(string[] args)
{
string ticker = "^DJI";
Uri siteUri = new Uri("http://quote.yahoo.com/d/quotes.csv?s=" +
ticker + "&f=sl1d1t1c1ohgvj1pp2owern&e=.csv");

WebClient web = new WebClient();
string data = web.DownloadString(siteUri);

Quote q = Quote.Parse(data);

Console.WriteLine(string.Format("{0} {1} Last:{2} Change:{3}
Bid:{4} Offer: {5}", q.Ticker, q.Name, q.Last, q.Change, q.Bid, q.Offer));
Console.ReadLine();
}
}

public class Quote
{
public double Last { get; set; }
public string Ticker { get; set; }
public double Change { get; set; }
public string Name { get; set; }
public double Bid { get; set; }
public double Offer { get; set; }

public static Quote Parse(string data)
{
string[] fields = data.Replace("\"", "").Split(',');
Quote q = new Quote
{
Ticker = fields[0].ToUpper(),
Last = Convert.ToDouble(fields[1]),
Change = Convert.ToDouble(fields[4]),
Bid = Convert.ToDouble(fields[5]),
Offer = Convert.ToDouble(fields[6]),
Name = fields[7].ToUpper()
};

return q;
}
}


 
Reply With Quote
 
 
 
 
Andrew Morton
Guest
Posts: n/a
 
      15th May 2009
Mikeerh wrote:
> I have a ticker sample running with yahoo as provider.
> When it comes to indices they all start with a caret (^) like ^DJI.
> The framework converts this string internally into a %% before it is
> on the net (I saw it with wireshark) and than yahoo responds with a
> N/A ?? How can I get the framework to let the carret through??
>
> here is the sample code:


> string ticker = "^DJI";
> Uri siteUri = new Uri("http://quote.yahoo.com/d/quotes.csv?s=" + ticker +
> "&f=sl1d1t1c1ohgvj1pp2owern&e=.csv");


Have you tried ... + Server.UrlEncode(ticker) + ...?

Andrew


 
Reply With Quote
 
 
 
 
Andrew Morton
Guest
Posts: n/a
 
      15th May 2009
Mikeerh wrote:
> I have a ticker sample running with yahoo as provider.
> When it comes to indices they all start with a caret (^) like ^DJI.
> The framework converts this string internally into a %% before it is
> on the net (I saw it with wireshark) and than yahoo responds with a
> N/A ?? How can I get the framework to let the carret through??
>
> here is the sample code:


> string ticker = "^DJI";
> Uri siteUri = new Uri("http://quote.yahoo.com/d/quotes.csv?s=" + ticker +
> "&f=sl1d1t1c1ohgvj1pp2owern&e=.csv");


Have you tried ... + Server.UrlEncode(ticker) + ...?

Andrew


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems with carret in URL (real time ticker sample) Mikeerh Microsoft Dot NET 0 15th May 2009 05:12 AM
How to use symbol=["Ticker" "Enter ticker"] with Microsoft Excel 2 tickerguy Microsoft Access Queries 1 28th Jun 2008 10:47 PM
RSS Software - Mighty Ticker, RSS Ticker RSS Expert Freeware 0 6th Aug 2006 05:06 AM
TextBox carret not placed correctly Chien Lau Microsoft Dot NET Framework Forms 1 2nd Sep 2004 10:11 PM
How to chage Absolute url to relative url ,and relative url to absolute url gqtang Microsoft C# .NET 1 13th Sep 2003 05:22 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:11 AM.