deqian 写的web程序

 public string  getnews_gshq(string stockid)
{
if(stockid.Length>6)
{
arsr="";
}
else
{
switch(int.Parse(stockid.Substring(0,1)))
{
case 0:
arsr="szag";
break;
case 2:
arsr="szbg";
break;
case 6:
arsr="shag";
break;
case 9:
arsr="shbg";
break;
default:
break;
}
}
stockurl="http://www.stockstar.com/scripts/quoteISAPI.dll?MFCISAPICommand=dghq&code="+arsr+stockid;

regexstr=" <tr//s*class=e02//s*height=.*>..* </table>//s*. <p>";

WebRequest  request = WebRequest.Create(stockurl);
WebResponse response = request.GetResponse();
Stream resStream = response.GetResponseStream();
StreamReader sr = new StreamReader(resStream, System.Text.Encoding.Default);
Regex regex_Stock=new Regex(regexstr,RegexOptions.IgnoreCase|RegexOptions.Singleline);
MatchCollection mcoll= regex_Stock.Matches(sr.ReadToEnd());
string[] result=new string[mcoll.Count];
StringBuilder resbud=new StringBuilder();
for(int i=0;i <mcoll.Count;i++)
{
result[i]=mcoll[i].Value;
result[i]=Regex.Replace(result[i],@" ","");
//result[i]=Regex.Replace(result[i],@"/["," <");
//result[i]=Regex.Replace(result[i],@"/]",">");
result[i]=Regex.Replace(result[i],@" <[""A-Za-z0-9=#':;_/./-/%&?]*>",""); //过滤HTML标签
//result[i]=Regex.Replace(result[i],@" <[A-Za-z0-9=#':;_/./-/]*>",""); //过滤HTML标签
result[i]=Regex.Replace(result[i],@"/[[/u4e00-/u9fa5]*/]","");
result[i]=Regex.Replace(result[i],"/r","/r/n");
result[i]=Regex.Replace(result[i],"/n","/r/n");
result[i]=Regex.Replace(result[i],"/r/n/r/n","|");
result[i]=Regex.Replace(result[i],"//s*","");
resbud.Append(result[i].ToString());
}
resStream.Close();
sr.Close();
string[] gshq=resbud.ToString().Split('|');
int n=0;
for(int j=0;j <gshq.Length;j++)
{
if(gshq[j]!="")
{
if(n <gghq.Length)
{
gghq[n]=gshq[j];
n++;
}
}
}
string text1=gghq[0].ToString()+"$"+gghq[1].ToString()+"$"+gghq[2].ToString()+"$"+gghq[3].ToString()+"$"+gghq[4].Replace(",","").ToString()+"$"+gghq[5].Replace(",","").ToString()+"$"+gghq[6].Replace(",","").ToString()+"$"+gghq[7].Replace(",","").ToString()+"$"+gghq[8].ToString()+"$"+gghq[9].ToString()+"$"+gghq[10].Replace("成交时间:","").ToString();
return text1;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值