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

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

2012-01-06 
【虚心请教孟子与幕白兄弟】如何拆分取得 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()   ......


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


[解决办法]
拆分取得 html里的数组是什么意思?
这些html不是你的?是你通过类似WebRequest得到的?如果这样的话,就比较麻烦了,需要一行一行读取进行分析。或者使用WebBrowser等
[解决办法]
你在后台要对这些数据进行什么样的操作,如果是一一对应的取到多个数组里,比较麻烦,如果是按顺序把每一个元素提取并添加到同一个ArrayList里,也可以达到你的目的,就比较容易了
[解决办法]
try

string yourStr = ..............;
ArrayList al = new ArrayList();
MatchCollection mc = Regex.Matches(yourStr, @ "GameFT\[\d+\]=new\s+Array\((? <arr> [^\)]*)\) ", RegexOptions.IgnoreCase);
foreach (Match m in mc)
{
MatchCollection mc2 = Regex.Matches(m.Value, @ " '(? <con> [^ ']*) ' ");
foreach (Match m2 in mc2)
{
al.Add(m2.Groups[ "con "].Value);
}
}
[解决办法]
你是怎么用的,贴一下你的测试代码,尤其是怎么得到源字符串的代码

我的测试代码,用你上面的源字符串
string yourStr = .............;
ArrayList al = new ArrayList();
MatchCollection mc = Regex.Matches(yourStr, @ "GameFT\[\d+\]=new\s+Array\((? <arr> [^\)]*)\) ", RegexOptions.IgnoreCase);
foreach (Match m in mc)
{
MatchCollection mc2 = Regex.Matches(m.Value, @ " '(? <con> [^ ']*) ' ");
foreach (Match m2 in mc2)
{
al.Add(m2.Groups[ "con "].Value);
}
}

foreach (string s in al)
{
richTextBox2.Text += s + "\n ";
}

输出结果为:
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
1.400
0.500
O 1.5
U 1.5
1.150
0.710


1
0



[解决办法]
这个用我的代码测没问题的,结果如下,输出时因为太长,我用“___”把各项内容连起来了,如果只计算提取的时间,是在1秒钟以内的


221315___06-14 <br> 11:30a <br> <font style=background-color=red> 走地 </font> ___芬蘭超級聯賽___4032___4031___TPS 杜古[主]___洪卡___H___0 / 0.5___0.960___0.940___O2.5___U2.5___0.960___0.900___2.15___2.90___3.20___單___雙___2.01___1.89___221316___H___0___0.740___1.140___O1___U1___0.880___0.980___221317___06-14 <br> 11:30a <br> <font style=background-color=red> 走地 </font> ___芬蘭超級聯賽___4034___4033___TPS 杜古[主]___洪卡___H___0.5___1.260___0.700___O2.5 / 3___U2.5 / 3___0.700___1.160___________________________________________________221313___06-14 <br> 11:30a <br> <font style=background-color=red> 走地 </font> ___芬蘭超級聯賽___4036___4035___古迪比[主]___VPS 華沙___H___0 / 0.5___0.910___0.990___O2.5___U2.5___0.910___0.950___2.10___3.10___3.10___單___雙___2.00___1.90___221314___H___0 / 0.5___1.110___0.770___O1___U1___0.850___1.010___221319___06-14 <br> 11:30a <br> <font style=background-color=red> 走地 </font> ___芬蘭超級聯賽___4038___4037___古迪比[主]___VPS 華沙___H___0.5___1.210___0.720___O2 / 2.5___U2 / 2.5___1.110___0.750___________________________________________________221321___06-14 <br> 11:30a <br> <font style=background-color=red> 走地 </font> ___芬蘭超級聯賽___4040___4039___查路[主]___維京吉特___H___0.5___1.040___0.860___O2.5___U2.5___0.850___1.010___1.90___3.55___3.20___單___雙___1.98___1.92___221322___H___0 / 0.5___1.180___0.700___O1___U1___0.890___0.970___221323___06-14 <br> 11:30a <br> <font style=background-color=red> 走地 </font> ___芬蘭超級聯賽___4042___4041___查路[主]___維京吉特___H___0 / 0.5___0.720___1.210___O2 / 2.5___U2 / 2.5___1.110___0.750___________________________________________________221325___06-14 <br> 11:30a <br> <font style=background-color=red> 走地 </font> ___芬蘭超級聯賽___4044___4043___夏卡[主]___譚柏利___C___0___1.040___0.860___O2 / 2.5___U2 /2.5___0.830___1.030___2.60___2.40___3.10___單___雙___2.01___1.89___221326___C___0___1.010___0.870___O0.5 / 1___U0.5 / 1___1.160___0.700___221327___06-14 <br> 11:30a <br> <font style=background-color=red> 走地 </font> ___芬蘭超級聯賽___4046___4045___夏卡[主]___譚柏利___C___0 / 0.5___0.720___1.210___O2___U2___1.100___0.760___________________________________________________222125___06-14 <br> 11:30a___夢幻組合___4108___4107___古迪比[中]___TPS 杜古___H___0___0.880___1.000___O2.5 / 3___U2.5 / 3___0.920___0.940____________單___雙___1.93___1.93___222126___H___0___0.880___1.000___O1 / 1.5___U1 / 1.5___0.800___1.060___222127___06-14 <br> 11:30a___夢幻組合___4110___4109___古迪比[中]___譚柏利___H___0 / 0.5___1.020___0.860___O2.5___U2.5___0.960___0.900____________單___雙___1.93___1.93___222128___H___0___0.740___1.140___O1___U1___0.960___0.900___222129___06-14 <br> 11:30a___夢幻組合___4112___4111___查路[中]___TPS 杜古___H___0___0.860___1.020___O2.5 / 3___U2.5 / 3___0.930___0.930____________單___雙___1.93___1.93___222130___H___0___0.850___1.030___O1 / 1.5___U1 / 1.5___0.800___1.060___222131___06-14 <br> 11:30a___夢幻組合___4114___4113___TPS 杜古[中]___譚柏利___H___0 / 0.5___0.970___0.910___O2.5___U2.5___0.910___0.950____________單___雙___1.93___1.93___222132___H___0___0.680___1.200___O1___U1___0.950___0.910___222133___06-14 <br> 11:30a___夢幻組合___4116___4115___古迪比[中]___查路___C___0___0.980___0.900___O2.5 / 3___U2.5 / 3___0.990___0.870____________單___雙___1.93___1.93___222134___C___0___0.960___0.920___O1 / 1.5___U1 / 1.5___0.860___1.000___222135___06-14 <br> 11:30a___夢幻組合___4118___4117___查路[中]___譚柏利___H___0 / 0.5___0.950___0.930___O2.5___U2.5___1.000___0.860____________單___雙___1.93___1.93___222136___H___0___0.660___1.220___O1___U1___0.970___0.890___221337___06-14 <br> 12:00a <br> <font style=background-color=red> 走地 </font> ___挪威盃___4092___4091___通斯堡[主]___桑德菲傑___C___1___0.940___0.960___O3.5 / 4___U3.5 / 4___1.050___0.810___5.05___1.45___3.80___單___雙___1.98___1.92___221338___C___0.5___0.840___1.040___O1.5 / 2___U1.5 / 2___0.890___0.970___221333___06-14 <br> 12:00a <br> <font style=background-color=red> 走地 </font> ___挪威盃___4096___4095___侯治森華特[主]___斯達___C___2.5 / 3___0.980___0.900___O4___U4___0.750___1.110___15.50___1.05___7.50___單___雙___1.98___1.92______________________________221269___06-14 <br> 12:15a <br> <font style=background-color=red> 走地 </font> ___歐 U21___4082___4081___捷克[U21][中]___塞爾維亞[U21]___C___0 / 0.5___0.910___0.990___O2___U2___0.860___1.000___3.00___2.15___3.10___單___雙___2.00___1.90___221270___C___0___1.180___0.700___O0.5 / 1___U0.5 / 1___0.940___0.920___221267___06-14 <br> 12:15a <br> <font style=background-color=red> 走地 </font> ___歐 U21___4084___4083___捷克[U21][中]___塞爾維亞[U21]___C___0___1.300___0.660___O1.5 / 2___U1.5 / 2___1.160___0.700___________________________________________________221787___06-14 <br> 01:00p <br> <font style=background-color=red> 走地 </font> ___瑞典甲組___4048___4047___安高平[主]___米亞爾比___C___0___1.120___0.780___O2.5___U2.5___0.770___1.090___2.70___2.35___3.10___單___雙___2.00___1.90___221788___C___0___1.020___0.860___O1___U1___0.860___1.000___221789___06-14 <br> 01:00p <br> <font style=background-color=red> 走地 </font> ___瑞典甲組___4050___4049___安高平[主]___米亞爾比___C___0 / 0.5___0.760___1.160___O2 / 2.5___U2 / 2.5___0.980___0.880___________________________________________________221347___06-14 <br> 01:00p <br> <font style=background-color=red> 走地 </font> ___瑞典甲組___4052___4051___哈肯[主]___盧恩斯基爾___H___0.5 / 1___0.960___0.940___O2.5___U2.5___1.050___0.810___1.60___4.95___3.40___單___雙___1.99___1.91___221348___H___0 / 0.5___0.850___1.030___O1___U1___0.980___0.880___221349___06-14 <br> 01:00p <br> <font style=background-color=red> 走地 </font> ___瑞典甲組___4054___4053___哈肯[主]___盧恩斯基爾___H___0.5___0.700___1.240___O2.5 / 3___U2.5 / 3___0.760___1.100___________________________________________________221341___06-14 <br> 01:00p <br

热点排行