<%@ 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"/>
<%@ 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'