简单的天气预报

<% @ Control Language = " C# "   %>


<% @ Import Namespace = " System "   %>
<% @ Import Namespace = " System.Configuration "   %>
<% @ Import Namespace = " System.Data "   %>
<% @ Import Namespace = " System.Web " %>
<% @ Import Namespace = " System.Web.Security "   %>
<% @ Import Namespace = " System.Web.UI "   %>
<% @ Import Namespace = " System.Web.UI.WebControls "   %>
<% @ Import Namespace = " System.Web.UI.WebControls.WebParts "   %>
<% @ Import Namespace = " System.Web.UI.HtmlControls "   %>
<% @ Import Namespace = " Microsoft.SharePoint "   %>
<% @ Import Namespace = " System.Net "   %>
<% @ Import Namespace = " System.IO "   %>


< script runat = " server " >
    
  

    
protected   void  Page_Load( object  sender, EventArgs e)
    
{

        
string css163 = "<link href=\"http://news.163.com/css/news_weather.css\" rel=\"stylesheet\" type=\"text/css\" />";
        if (!Page.IsPostBack)
            txtlit.Text 
= getHtml("http://news.163.com/weather/news/qx1/56294.html");
        txtlit.Text 
= txtlit.Text.Replace(css163, String.Empty);
        txtlit.Text 
= "<font color=#333333>" + txtlit.Text + "</font>";
       
  }
   
   
public   static   string  getHtml( string  url)  {

        System.Net.WebClient myWebClient 
= new System.Net.WebClient();
        
byte[] myDataBuffer = myWebClient.DownloadData(url);
        
string str = Encoding.Default.GetString(myDataBuffer);
        
int begin = str.IndexOf("<a");
        
int count = str.IndexOf("</a>"- begin;
        str 
= str.Remove(begin, count + 4);
        
return str;

    }

</ script >
< asp:Literal ID = " txtlit "  runat = " server " />

http://news.163.com/weather/news/qx1/56294.html  //56294是成都的代码
其它成都的代码:
"安徽"'58321'
"黑龙江"'50953',
"山东"'54823',
"北京"'54511',"湖北"'57494',"山西"'53772',"福建"'59134',"湖南"'57679',"陕西"'57036',"甘肃"'52889',"吉林"'54172',"上海"'58367',"广东"'59287',"江苏"'58238',"四川"'56294',"广西"'59431',"江西"'58606',"天津"'54527',"贵州"'57816',"辽宁"'54342',"西藏"'55591',"海南"'52856',"内蒙古"'53463',"新疆"'51463',"河北"'53698',"宁夏"'53614',"云南"'56778',"河南"'57083',"青海"'52866',"浙江"'58457',"重庆"'57516'

转载于:https://www.cnblogs.com/jlydboy/articles/1437174.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值