日期:2014-05-17 浏览次数:20903 次
public static string GetContent(string url, string regStr)
{
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url);
req.Method = "GET";
req.ContentType = "application/x-www-form-urlencoded";
HttpWebResponse wsp = (HttpWebResponse)req.GetResponse();
Stream st = wsp.GetResponseStream();
if (wsp.ContentEncoding.ToLower().Contains("gzip"))
{
st = new GZipStream(st, CompressionMode.Decompress);
}
StreamReader sr = new StreamReader(st, Encoding.Default);
string value = sr.ReadToEnd();
Regex reg = new Regex(regStr);
foreach (Match m in reg.Matches(value))
{
var a = m.Groups[1].Value;
}
string s = reg.Matches(value)[0].Groups[1].Value;
return s;
}