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;
}
deqian 写的web程序
最新推荐文章于 2024-07-24 20:11:59 发布