. Net C # obtain QQ weather code
/// <Summary>
/// 2011-06-16? T juwen
/// </Summary>
Public partial class QQweather: System. Web. UI. Page
{
Public string selectcity = "1 ";
/// <Summary>
///
/// </Summary>
/// <Param name = "sender"> </param>
/// <Param name = "e"> </param>
Protected void Page_Load (object sender, EventArgs e)
{
ServicePointManager. ServerCertificateValidationCallback = new System. Net. Security. RemoteCertificateValidationCallback (CheckValidationResult );
HttpWebRequest req = (HttpWebRequest) WebRequest. CreateDefault (new Uri ("https Tutorial: // www.dusystem.com/qqweather.asp X "));
Req. Method = "GET ";
HttpWebResponse res = (HttpWebResponse) req. GetResponse ();
Selectcity = DropDownList1.SelectedValue. ToString ();
If (! IsPostBack)
{
This. DropDownList1.DataSource = CreateDataSource ();
DropDownList1.DataTextField = "WeatherTextField ";
DropDownList1.DataValueField = "WeatherValueField ";
// Bind the data to the control.
DropDownList1.DataBind ();
// Set the default selected item, if desired.
DropDownList1.SelectedIndex = 0;
Selectcity = @ "1 ";
}
}
/// <Summary>
///
/// </Summary>
/// <Param name = "sender"> </param>
/// <Param name = "e"> </param>
Protected void button#click (object sender, EventArgs e)
{
ServicePointManager. ServerCertificateValidationCallback = new System. Net. Security. RemoteCertificateValidationCallback (CheckValidationResult );
HttpWebRequest req = (HttpWebRequest) WebRequest. CreateDefault (new Uri ("https://www.dusystem.com/QQweather.aspx "));
Req. Method = "GET ";
HttpWebResponse res = (HttpWebResponse) req. GetResponse ();
Selectcity = DropDownList1.SelectedValue. ToString ();
}
/// <Summary>
/// <% # Selectcity %>
/// </Summary>
/// <Returns> </returns>
ICollection CreateDataSource ()
{
DataTable dt = new DataTable ();
Dt. Columns. Add (new DataColumn ("WeatherTextField", typeof (String )));
Dt. Columns. Add (new DataColumn ("WeatherValueField", typeof (String )));
Dt. Rows. Add (CreateRow ("Hong Kong", "1", dt ));
Dt. Rows. Add (CreateRow ("Australia? "," 2 ", dt ));
Dt. Rows. Add (CreateRow ("Ha ??? I "," 17 ", dt ));
Dt. Rows. Add (CreateRow ("? Why? Mu? "," 28 ", dt ));
Dt. Rows. Add (CreateRow ("West ?? "," 56 ", dt ));
Dt. Rows. Add (CreateRow ("? State "," 57 ", dt ));
Dt. Rows. Add (CreateRow ("Hohhot", "69", dt ));
Dt. Rows. Add (CreateRow ("? Chuan "," 78 ", dt ));
Dt. Rows. Add (CreateRow ("shi jia? "," 82 ", dt ));
Dt. Rows. Add (CreateRow ("Taiyuan", "84", dt ));
Dt. Rows. Add (CreateRow ("? Spring "," 103 ", dt ));
Dt. Rows. Add (CreateRow ("? C? "," 115 ", dt ));
Dt. Rows. Add (CreateRow ("Beijing'," 125 ", dt ));
Dt. Rows. Add (CreateRow ("Tianjin", "127", dt ));
Dt. Rows. Add (CreateRow ("?? "," 140 ", dt ));
Dt. Rows. Add (CreateRow ("pull? "," 150 ", dt ));
Dt. Rows. Add (CreateRow ("Chengdu", "166", dt ));
Dt. Rows. Add (CreateRow ("Kunming", "179", dt ));
Dt. Rows. Add (CreateRow ("Xi'an", "186", dt ));
Dt. Rows. Add (CreateRow ("? State "," 189 ", dt ));
Dt. Rows. Add (CreateRow ("? H "," 211 ", dt ));
Dt. Rows. Add (CreateRow ("weight? C "," 212 ", dt ));
Dt. Rows. Add (CreateRow ("? SHA "," 218 ", dt ));
Dt. Rows. Add (CreateRow ("?? "," 227 ", dt ));
Dt. Rows. Add (CreateRow ("Guilin", "232", dt ));
Dt. Rows. Add (CreateRow ("Nanjing", "244", dt ));
Dt. Rows. Add (CreateRow ("Hefei", "248", dt ));
Dt. Rows. Add (CreateRow ("Shanghai", "252", dt ));
Dt. Rows. Add (CreateRow ("Hangzhou", "255", dt ));
Dt. Rows. Add (CreateRow ("Nanchang", "264", dt ));
Dt. Rows. Add (CreateRow ("Fuzhou", "276", dt ));
Dt. Rows. Add (CreateRow ("? North "," 280 ", dt ));
Dt. Rows. Add (CreateRow ("? B? "," 287 ", dt ));
Dt. Rows. Add (CreateRow ("? V State "," 292 ", dt ));
Dt. Rows. Add (CreateRow ("South ?? "," 295 ", dt ));
Dt. Rows. Add (CreateRow ("Shenzhen", "296", dt ));
Dt. Rows. Add (CreateRow ("Haikou", "303", dt ));
DataView dv = new DataView (dt );
Return dv;
}
/// <Summary>
///
/// </Summary>
/// <Param name = "Text"> </param>
/// <Param name = "Value"> </param>
/// <Param name = "dt"> </param>
/// <Returns> </returns>
DataRow CreateRow (String Text, String Value, DataTable dt)
{
DataRow dr = dt. NewRow ();
Dr [0] = Text;
Dr [1] = Value;
Return dr;
}
Public bool CheckValidationResult (object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
{
// Directly confirm, otherwise it cannot be opened
Return true;
}