{
WebRequest wreq=WebRequest.Create("http://weather.yahoo.com/forecast/CHXX0037_c.html");
HttpWebResponse wresp=(HttpWebResponse)wreq.GetResponse();
string HTML =""; Stream s=wresp.GetResponseStream();
StreamReader objReader = new StreamReader(s);
string sLine = ""; int i = 0;
while (sLine!=null) { i++; sLine = objReader.ReadLine(); if (sLine!=null) HTML += sLine; }
String temp= ""; int start,stop;
start = HTML.IndexOf("<!-- CURCON-->",0,HTML.Length);
stop = HTML.IndexOf("<!-- END CURCON-->",0,HTML.Length);
temp = HTML.Substring(start, stop - start); start = temp.IndexOf("<b>"); stop = temp.IndexOf("</b>");
string degree = temp.Substring(start+3,stop - start -3);
start = temp.IndexOf("<img"); stop = temp.IndexOf("</td>",start);
string img = temp.Substring(start,stop - start); lblWeather.Text = degree + "<br>" + img;
}
private void btnGet2_Click(object sender, System.EventArgs e) { WebRequest wreq=WebRequest.Create("http://cn.weather.yahoo.com/CHXX/CHXX0037/index_c.html");
HttpWebResponse wresp=(HttpWebResponse)wreq.GetResponse();
string HTML =""; Stream s=wresp.GetResponseStream();
StreamReader objReader = new StreamReader(s,System.Text.Encoding.GetEncoding("GB2312"));
string sLine = ""; int i = 0;
while (sLine!=null) { i++; sLine = objReader.ReadLine(); if (sLine!=null) HTML += sLine; }
String temp= ""; int start,stop;
start = HTML.IndexOf("<table border=0 cellpadding=2 cellspacing=1 bgcolor=9999cc width="85%">",0,HTML.Length);
stop = HTML.IndexOf("</table>",start)+8;
temp = HTML.Substring(start, stop - start); Weather2.Text = temp; } } }
|