【发布时间】:2013-11-22 09:18:10
【问题描述】:
我正在向金融 yahoo 发送请求,如果符号最大为 200,我的以下代码工作正常。如果符号超过 200,我收到错误“远程服务器返回错误:(414) 请求 URI 太长。”
实际符号超过20000个
你能提出一个可能的解决方案吗?
string yahooQuoteUrl = "http://finance.yahoo.com/d/quotes.csv?s=";
string yahooParameters = "&f=sl1d1yxn";
string Url ="";
SqlConnection sqlConnection = new SqlConnection(con1);
SqlCommand sqlCommand = new SqlCommand("SELECT Symbol FROM PM_Securities",sqlConnection);
sqlConnection.Open();
SqlDataReader reader = sqlCommand.ExecuteReader();
GridView2.DataSource = reader;
GridView2.DataBind();
string symbols= GridView2.Rows[0].Cells[0].Text;
string csvData;
using (WebClient web = new WebClient())
{
Url = yahooQuoteUrl + symbols+ yahooParameters;
csvData = web.DownloadString(Url);
}
List<Price> prices = Parse(csvData);
GridView1.DataSource = prices;
GridView1.DataBind();
【问题讨论】:
-
将作业拆分为多个少于 200 个的单独请求?
-
尝试使用 POST 而不是 GET
-
我只是更新我的代码。我的符号是从我的数据库中检索到的,所以我不知道符号的确切数量。我的一个客户可能有 10000 或其他客户可能有 30000 或其他客户可能有 100。
-
你能给我提供使用 POST 的例子吗
标签: c# url webclient yahoo yahoo-finance