zoukankan      html  css  js  c++  java
  • 使用webservice获得天气,基金,股票等信息 Virus

    protected void Button1_Click(object sender, EventArgs e)
        
    {
            cn.com.webxml.www.WeatherWebService weather 
    = new cn.com.webxml.www.WeatherWebService();
            
    string[] weathers = weather.getWeatherbyCityName("58367");
            
    this.TextBox1.Text = weathers[10].ToString();
            cn.com.webxml.www.ChinaOpenFundWS fund 
    = new cn.com.webxml.www.ChinaOpenFundWS();
            DataSet ds
    = fund.getFundCodeNameDataSet();
            
    this.GridView1.DataSource = ds.Tables[0].DefaultView;
            
    this.GridView1.DataBind();
            cn.com.webxml.www.ChinaStockSmallImageWS stock 
    = new cn.com.webxml.www.ChinaStockSmallImageWS();
            
    byte[] b = stock.getSmallImageByte("sh000001"byte.MaxValue);
            Random random 
    = new Random();

            
    string imageName=random.Next().ToString()+ ".jpg";
            
    string myUrl = HttpContext.Current.Server.MapPath(this.Request.ApplicationPath) + imageName;
            FileStream fs 
    = new FileStream(myUrl, FileMode.OpenOrCreate);
            BinaryWriter w 
    = new BinaryWriter(fs);
            w.BaseStream.Write(b, 
    0, b.Length);
            w.Flush();
            w.Close();

            
    this.Image1.ImageUrl = Context.Request.ApplicationPath  + imageName;
            System.Drawing.Bitmap bitmap 
    = new System.Drawing.Bitmap(myUrl);
            
    this.Image1.Width = bitmap.Width;
            
    this.Image1.Height = bitmap.Height;
        }
    给大家介绍一个很好的网站,提供了一些常用的web服务,例如时刻表,天气,基金,股票,IP等,大家可以自己去看看。
    http://www.webxml.com.cn/zh_cn/web_services.aspx
    下面我演示一个例子,获取天气,基金列表和股票走势图,具体的基金值需要联系网站,用他分配的用户名做参数才可以访问。


    【Blog】http://virusswb.cnblogs.com/

    【MSN】jorden008@hotmail.com

    【说明】转载请标明出处,谢谢

    反馈文章质量,你可以通过快速通道评论:

  • 相关阅读:
    2491 玉蟾宫
    1704 卡片游戏
    1020 孪生蜘蛛
    1215 迷宫
    3149 爱改名的小融 2
    1316 文化之旅 2012年NOIP全国联赛普及组
    1664 清凉冷水
    157. [USACO Nov07] 奶牛跨栏
    [SCOI2005]繁忙的都市
    【NOIP2014模拟赛No.1】我要的幸福
  • 原文地址:https://www.cnblogs.com/virusswb/p/1205025.html
Copyright © 2011-2022 走看看