摩擦压力机厂家
免费服务热线

Free service

hotline

010-00000000
摩擦压力机厂家
热门搜索:
行业资讯
当前位置:首页 > 行业资讯

用C读取sina天气预报到wap页面

发布时间:2021-01-20 16:48:18 阅读: 来源:摩擦压力机厂家

<%@ Register TagPrefix="mobile"

Namespace="bileControls"

Assembly="bile" %><%@ Page language="c#"

Codebehind="" Inherits="ather"

AutoEventWireup="false" %><mobile:form id="Form1" runat="server">

<FONT face="宋体">

<mobile:Label id="Label3" runat="server"

Font-Bold="True">【生活资讯】</mobile:Label>

<mobile:Label id="Label1" runat="server"

Font-Italic="True">==天气预报==</mobile:Label>

<mobile:Label id="l_date" runat="server"></mobile:Label>

<mobile:Label id="l_city" runat="server"></mobile:Label>

<mobile:Label id="l_wea" runat="server"></mobile:Label>

<mobile:Label id="l_sky" runat="server"></mobile:Label>

<mobile:Label id="l_w1" runat="server"></mobile:Label>

<mobile:Label id="l_w2" runat="server"></mobile:Label>

<mobile:Label id="l_w3" runat="server"></mobile:Label>

<mobile:Label id="Label2" runat="server">【请选择城市名】:</mobile:Label>

<mobile:SelectionList id="s_weather" runat="server">

<Item Value="深圳" Text="深圳" Selected="True"></Item>

<Item Value="广州" Text="广州"></Item>

<Item Value="上海" Text="上海"></Item>

<Item Value="北京" Text="北京"></Item>

<Item Value="天津" Text="天津"></Item>

<Item Value="武汉" Text="武汉"></Item>

<Item Value="重庆" Text="重庆"></Item>

<Item Value="成都" Text="成都"></Item>

<Item Value="南京" Text="南京"></Item>

<Item Value="香港" Text="香港"></Item>

<Item Value="澳门" Text="澳门"></Item>

</mobile:SelectionList>

<mobile:Command id="Command1" runat="server">查 询</mobile:Command>

<mobile:Link id="Link1" runat="server"

NavigateUrl="../px#Goodview">首

页</mobile:Link></FONT></mobile:form>

public class weather : bilePage

...{

protected bel Label1;

protected bel Label2;

protected lectionList s_weather;

protected bel l_date;

protected bel l_city;

protected bel l_wea;

protected bel l_sky;

protected bel l_w1;

protected bel l_w2;

protected bel l_w3;

protected nk Link1;

protected mand Command1;

protected bel Label3;

protected rm Form1;

private void Page_Load(object sender, entArgs e)

...{

// 在此处放置用户代码以初始化页面

if (!PostBack)

...{

string city = "深圳";

int start,stop;

string weather1,weather2,wea;

string wea_city = weather_city(city);

wea_city = wea_place(" ","");

start = wea_dexOf("<b>",0,wea_ngth);

stop = wea_dexOf("</b>", start);

weather1 = wea_bstring(start, stop-start).Trim() + " ";

weather1 = bstring(3,8).Trim();

start =

wea_dexOf("<tdstyle="font-size:40px;font-family:TimesNewRoman;font-weight:bold;">",0,wea_ngth);

stop = wea_dexOf("℃",start) + 40;

weather2 = wea_bstring(start, stop-start);

weather2 = bstring(stop-start-42,40).Trim();

weather2 = place(" ","");

start = wea_dexOf("<fontcolor=#183888><b>", 0,

wea_ngth);

stop = wea_dexOf("</b></font>",start);

wea = wea_bstring(start,stop-start);

wea = bstring(22,ngth-22) + "kbrk";

wea = place(" ", "");

wea = place(">", "k");

wea = place("<", "k");

wea = place("kbrk", "k");

string [] wall = null;

char[] seperator = ...{'k'};

wall = lit(seperator);

/**///////////////////////////////////////

l_xt = "[城市]:" + city;

l_xt = "[天气]:" + weather1;

l_xt = "[温度]:" + weather2;

/**////////

l_xt = wall[0];

l_xt = wall[1];

l_xt = wall[2];

l_xt = wall[3];

}

}

Web 窗体设计器生成的代码#region Web 窗体设计器生成的代码

override protected void OnInit(EventArgs e)

...{

//

// CODEGEN: 该调用是 Web 窗体设计器所必需的。

//

InitializeComponent();

Init(e);

}

/**//// <summary>

/// 设计器支持所需的方法 - 不要使用代码编辑器修改

/// 此方法的内容。

/// </summary>

private void InitializeComponent()

...{

ick += new entHandler(mand1_Click);

ad += new entHandler(ge_Load);

}

#endregion

private void Command1_Click(object sender, entArgs e)

...{

string city = s_im();

int start,stop;

string weather1,weather2,wea;

string wea_city = weather_city(city);

wea_city = wea_place(" ","");

start = wea_dexOf("<b>",0,wea_ngth);

stop = wea_dexOf("</b>", start);

weather1 = wea_bstring(start, stop-start).Trim() + " ";

weather1 = bstring(3,8).Trim();

start =

wea_dexOf("<tdstyle="font-size:40px;font-family:TimesNewRoman;font-weight:bold;">",0,wea_ngth);

stop = wea_dexOf("℃",start) + 40;

weather2 = wea_bstring(start, stop-start);

weather2 = bstring(stop-start-42,40).Trim();

weather2 = place(" ","");

start = wea_dexOf("<fontcolor=#183888><b>", 0,

wea_ngth);

stop = wea_dexOf("</b></font>",start);

wea = wea_bstring(start,stop-start);

wea = bstring(22,ngth-22) + "kbrk";

wea = place(" ", "");

wea = place(">", "k");

wea = place("<", "k");

wea = place("kbrk", "k");

string [] wall = null;

char[] seperator = ...{'k'};

wall = lit(seperator);

/**///////////////////////////////////////

l_xt = "[城市]:" + city;

l_xt = "[天气]:" + weather1;

l_xt = "[温度]:" + weather2;

/**////////

l_xt = wall[0];

l_xt = wall[1];

l_xt = wall[2];

l_xt = wall[3];

}

public string weather_city(string city)

...{

string temp = null;

try

...{

string strURL =

"";

HttpWebRequest request;

request = (HttpWebRequest)eate(strURL);

thod="POST"; //Post请求方式

ntentType="application/x-www-form-urlencoded"; //内容类型

string paraUrlCoded = lEncode("city");

//参数经过URL编码

paraUrlCoded = paraUrlCoded + "=" +

lEncode(city,

tEncoding("GB2312"));

byte[] payload;

payload =

tEncoding("GB2312").GetBytes(paraUrlCoded);

//将URL编码后的字符串转化为字节

ntentLength = ngth; //设置请求的ContentLength

Stream writer = tRequestStream(); //获得请求流

ite(payload,0,ngth); //将请求参数写入流

ose(); //关闭请求流

HttpWebResponse response;

response = (HttpWebResponse)tResponse(); //获得响应流

Stream s;

s = tResponseStream();

StreamReader objReader = new

StreamReader(s,tEncoding("GB2312"));

string HTML = "";

string sLine = "";

int i = 0;

while (sLine!=null)

...{

i++;

sLine = adLine();

if (sLine!=null)

HTML += sLine;

}

HTML = place("&lt;","<");

HTML = place("&gt;",">");

int start,stop;

start = dexOf("<img

src="",0,ngth);

stop = dexOf("<td

background=",start);

temp = bstring(start, stop - start);

}

catch (Exception x)

...{

}

return temp;

}

}

买彩票的软件有哪些

三国霸无限金币版

王城英雄无限钻石版