using System.IO;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
public string GetHL(int pageindex)
{
string hl = null;
try
{
string tempurl = "http://www.boc.cn/sourcedb/whpj/index.html";
if (pageindex > 1)
tempurl = "http://www.boc.cn/sourcedb/whpj/index_" + (pageindex - 1).ToString() + ".html";
HttpWebRequest webr = (HttpWebRequest)WebRequest.Create(tempurl);//创建请求
HttpWebResponse wb = (HttpWebResponse)webr.GetResponse();
Stream sr = wb.GetResponseStream();//得到返回数据流
StreamReader sr1 = new StreamReader(sr, Encoding.GetEncoding("utf-8"));//用于读取数据流的内容
string zz = sr1.ReadToEnd();//读取完成
sr1.Close();
wb.Close();//关闭
string temp = "<table width=\"880\" id=\"documentContainer\" border=\"0\" cellpadding=\"5\" cellspacing=\"1\" bgcolor=\"#EAEAEA\">[\\s\\S]*?</table>";
hl = Regex.Match(zz, temp, RegexOptions.IgnoreCase).Value;
return hl;
}
catch { return null; }
}
- 本文标题: 抓取 中国银行外汇牌价表显示
- 文章分类:【.NET/Web】
- 非特殊说明,本文版权归【胡同里的砖头】个人博客 所有,转载请注明出处.