日期:2014-05-17 浏览次数:20730 次
List<StockInfo> result = cli.FindAllAs<StockInfo>().ToList();
Console.WriteLine("begin:" + DateTime.Now.ToString());
Parallel.ForEach(result, (item) =>
{
try
{
ReadUrlContent("http://dataapi.eastmoney.com:8080/bbsj/stock.aspx?code=" + item.StockCode + "", item.StockCode);
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString() + item.StockCode);
}
});
Console.WriteLine("end:" + DateTime.Now.ToString());
Console.WriteLine(DateTime.Now.ToString());
public static void ReadUrlContent(string rUrl, string code)
{
byte[] buf = new byte[8192];
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(rUrl);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream resStream = response.GetResponseStream();
string tempString = null;
int count = 0;
using (FileStream fs = new FileStream("D:\\eastmoney\\data\\bbsj\\page\\" + code + ".html", FileMode.OpenOrCreate, FileAccess.Write))
{
do
{
count = resStream.Read(buf, 0, buf.Length);
if (resStream.Read(buf,&