首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

【虚心请问孟子与幕白兄弟】怎么拆分取得 html里的数组。

2012-01-10 
【虚心请教孟子与幕白兄弟】如何拆分取得 html里的数组。。。。。。。。。。。。。。。。。。htmlheadtitle/titlemeta

【虚心请教孟子与幕白兄弟】如何拆分取得 html里的数组。。。。。。。。。。。。。。。。。。
<html>
<head>
<title> </title>
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=big5 ">
<script   language= "JavaScript ">
<!--
if(self   ==   top)   location= 'http://www.www.com/ '
parent.username= 'c5k00144 ';
parent.maxcredit= '1 ';
parent.code= ' ';
parent.uid= '76b1d07em21d900l68e86 ';


parent.ltype= '3 ';
parent.str_even   =   '和局 ';
parent.str_submit   =   '確認 ';
parent.str_reset   =   '重設 ';
parent.langx= 'zh-tw ';
parent.rtype= 're ';
parent.sel_lid= ' ';
parent.retime=60;
parent.str_renew   =   '秒自動更新 ';
parent.t_page=0.5;
parent.gamount=2;
parent.GameFT[0]=new   Array( '220929 ', '67 ', '美洲金盃 ', '3032 ', '3031 ', '墨西哥[中] ', '巴拿馬 ', 'H ', '0   /   0.5 ', '1.080 ', '0.820 ', 'O   1.5   /   2 ', 'U   1.5   /   2 ', '0.850 ', '1.010 ', ' ', ' ', ' ', '1 ', '0 ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');
//server
parent.GameFT[1]=new   Array( '221265 ', '67 ', '美洲金盃 ', '3078 ', '3077 ', '墨西哥[中] ', '巴拿馬 ', 'H ', '0.5 ', '1.400 ', '0.500 ', 'O   1.5 ', 'U   1.5 ', '1.150 ', '0.710 ', ' ', ' ', ' ', '1 ', '0 ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');
//server

function   onLoad(){
if(top.SI2_mem_index.mem_order.location   ==   'about:blank ')
top.SI2_mem_index.mem_order.location   =   'http://www.s1166.com/app/member/select.php?uid=76b1d07em21d900l68e86&langx=zh-tw ';
if(parent.retime   >   0)
parent.retime_flag= 'Y ';
else
parent.retime_flag= 'N ';
parent.loading_var   =   'N ';
if(parent.loading   ==   'N '   &&   parent.ShowType   !=   ' '){
parent.ShowGameList();
parent.body_browse.document.all.LoadLayer.style.display   =   'none ';
}
}

function   onUnLoad(){
x   =   parent.body_browse.pageXOffset;
y   =   parent.body_browse.pageYOffset;
parent.body_browse.scroll(x,y);
obj_layer   =   parent.body_browse.document.getElementById( 'LoadLayer ');
obj_layer.style.display   =   'block ';
parent.body_browse.document.getElementById( 'download ').title= 'DownLoad   127 ';

}

//   -->
window.defaultStatus= "Wellcome................. "
</script>
</head>
<body   bgcolor= "#FFFFFF "   onLoad= "onLoad(); "   onUnLoad= "onUnLoad() ">
<img   id=im0   width=0   height=0> <img   id=im1   width=0   height=0> <img   id=im2   width=0   height=0> <img   id=im3   width=0   height=0> <img   id=im4   width=0   height=0>
<img   id=im5   width=0   height=0> <img   id=im6   width=0   height=0>



</body>
</html>


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

请教:如何把GameFT[0]=new   Array( '220929 ', '67 ', '美洲金盃 ', '3032 ', '3031 ', '墨西哥[中] ', '巴拿馬 ', 'H ', '0   /   0.5 ', '1.080 ', '0.820 ', 'O   1.5   /   2 ', 'U   1.5   /   2 ', '0.850 ', '1.010 ', ' ', ' ', ' ', '1 ', '0 ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');

GameFT[1]=new   Array()   ......
GameFT[2]=new   Array()   ......
GameFT[3]=new   Array()   ......
GameFT[*]=new   Array()   ......


每一组数组的值单独取出来,并放到后台创建新的数组中去?
给个思路或贴段代码都可以,希望能得到你们的帮忙,谢谢。


[解决办法]
可以在后台先写到数组,然后用循环,字符串拼接写成
string str= "GameFT[0]=new Array( '220929 ', '67 ', '美洲金盃 ', '3032 ', '3031 ', '墨西哥[中] ', '巴拿馬 ', 'H ', '0 / 0.5 ', '1.080 ', '0.820 ', 'O 1.5 / 2 ', 'U 1.5 / 2 ', '0.850 ', '1.010 ', ' ', ' ', ' ', '1 ', '0 ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '); "

public 类型
在页面上javascript里
<%=str%>
[解决办法]
only mark
[解决办法]
1,GameFT[0],GameFT[1],...已经是数组了。
放到后台创建新的数组中去?

需要提交到服务器端,可以把数组变成字符串提交啊。

document.getElementById( "T ").value=GameFT[0] //注意数组元素不得有,,否则需要自己拼接字付出。

<input type=hidden name= "T " />

服务器端得到Request.Form[ "T "],然后 Split即可啊

[解决办法]
用正则啊  取HMTL里的特征   

嗯我就不多言了 既然你已经点名了。。。
[解决办法]
说实话没怎么看懂题目,jf
[解决办法]
protected void Button1_Click(object sender, EventArgs e)
{


MatchCollection matchs = Regex.Matches(txtArr.Text, @ "(? <=new\sArray\(|,)([ " " ']*)(? <item> [^ ' " ",]*)\1(?=,|\);) ", RegexOptions.IgnoreCase);

foreach (Match m in matchs)
Response.Write(m.Value + " <br> ");
}


然后在页面的txtArr.Text,里面填写你上面的内容

我这里输出:
'220929 '
'67 '
'美洲金盃 '
'3032 '
'3031 '
'墨西哥[中] '
'巴拿馬 '
'H '
'0 / 0.5 '
'1.080 '
'0.820 '
'O 1.5 / 2 '
'U 1.5 / 2 '
'0.850 '
'1.010 '
' '
' '
' '
'1 '
'0 '
' '
' '
' '
' '
' '
' '
' '
' '
' '
'221265 '
'67 '
'美洲金盃 '
'3078 '
'3077 '
'墨西哥[中] '
'巴拿馬 '
'H '
'0.5 '
'0.500 '
'O 1.5 '
'U 1.5 '


'1.150 '
'0.710 '
' '
' '
' '
'1 '
'0 '
' '
' '
' '
' '
' '
' '
' '
' '
' '
y

[解决办法]
(? <=new\sarray\()[^)]+(?=\);)

用这个正则拿到array里面的所有元素后再spilt( ", ")

应该也可以

我上面的方法还是有点问题,因为匹配到了后面的一个y
[解决办法]
通过WebRequest得到的html,需要逐行读取、分析、判断,然后自己组合再提交。
[解决办法]
protected void Button1_Click(object sender, EventArgs e)
{

MatchCollection matchs = Regex.Matches(TextBox1.Text, @ "(? <=new\sarray\()[^)]+(?=\);) ", RegexOptions.IgnoreCase);
string strArr = string.Empty;
foreach (Match m in matchs)
{
strArr += m.Value+ ", ";
}
strArr = strArr.Substring(0, strArr.Length - 1);
string[] array = strArr.Split( ', ');


foreach (string s in array)
Response.Write(s + " <br> ");
}
[解决办法]
string str= @ " <html> <head> <title> </title> <meta http-equiv= " "Content-Type " " content= " "text/html; charset=big5 " "> <script language= " "JavaScript " "> <!--if(self == top) location= 'http://www.www.com/ 'parent.username= 'c5k00144 ';parent.maxcredit= '1 ';parent.code= ' ';parent.uid= '76b1d07em21d900l68e86 ';parent.ltype= '3 ';parent.str_even = '和局 ';parent.str_submit = '確認 ';parent.str_reset = '重設 ';parent.langx= 'zh-tw ';parent.rtype= 're ';parent.sel_lid= ' ';parent.retime=60;parent.str_renew = '秒自動更新 ';parent.t_page=0.5;parent.gamount=2;parent.GameFT[0]=new Array( '220929 ', '67 ', '美洲金盃 ', '3032 ', '3031 ', '墨西哥[中] ', '巴拿馬 ', 'H ', '0 / 0.5 ', '1.080 ', '0.820 ', 'O 1.5 / 2 ', 'U 1.5 / 2 ', '0.850 ', '1.010 ', ' ', ' ', ' ', '1 ', '0 ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');//serverparent.GameFT[1]=new Array( '221265 ', '67 ', '美洲金盃 ', '3078 ', '3077 ', '墨西哥[中] ', '巴拿馬 ', 'H ', '0.5 ', '1.400 ', '0.500 ', 'O 1.5 ', 'U 1.5 ', '1.150 ', '0.710 ', ' ', ' ', ' ', '1 ', '0 ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');//serverfunction onLoad(){if(top.SI2_mem_index.mem_order.location == 'about:blank ')top.SI2_mem_index.mem_order.location = 'http://www.s1166.com/app/member/select.php?uid=76b1d07em21d900l68e86&langx=zh-tw ';if(parent.retime > 0)parent.retime_flag= 'Y ';elseparent.retime_flag= 'N ';parent.loading_var = 'N ';if(parent.loading == 'N ' && parent.ShowType != ' '){parent.ShowGameList();parent.body_browse.document.all.LoadLayer.style.display = 'none ';}}function onUnLoad(){x = parent.body_browse.pageXOffset;y = parent.body_browse.pageYOffset;parent.body_browse.scroll(x,y);obj_layer = parent.body_browse.document.getElementById( 'LoadLayer ');obj_layer.style.display = 'block ';parent.body_browse.document.getElementById( 'download ').title= 'DownLoad 127 ';}// --> window.defaultStatus= " "Wellcome................. " " </script> </head> <body bgcolor= " "#FFFFFF " " onLoad= " "onLoad(); " " onUnLoad= " "onUnLoad() " "> <img id=im0 width=0 height=0> <img id=im1 width=0 height=0> <img id=im2 width=0 height=0> <img id=im3 width=0 height=0> <img id=im4 width=0 height=0> <img id=im5 width=0 height=0> <img id=im6 width=0 height=0> </body> </html> "; Regex reg = new Regex(@ "parent.GameFT\[0\]([\s\S]*?)function onLoad "); Match m = reg.Match(str); if (!m.Success) return; string sAryString = m.Result( "$1 "); reg = new Regex(@ "new\s*Array\(([\s\S]*?)\); "); MatchCollection ms = reg.Matches(sAryString); string[][] ary = new string[ms.Count][]; for (int i = 0; i < ms.Count; i++) { ary[i] = ms[i].Result( "$1 ").Split( ', '); } //显示 for (int i = 0; i < ary.Length; i++) { Response.Write( "数组 " + i.ToString() + "= "); for (int j = 0; j < ary[i].Length; j++) { Response.Write(ary[i][j] + "+ "); } Response.Write( " <BR> "); }


[解决办法]
上面数组中的 '号没有去除,lz 可自己处理一下.

热点排行