response = request.GetResponse() as HttpWebResponse;
//直到request.GetResponse()程序才开始向目标网页发送Post请求
instream = response.GetResponseStream();
sr = new StreamReader(instream, encoding);
//返回结果网页(html)代码
string content = sr.ReadToEnd();
err = string.Empty;
return content;
}
catch (Exception ex) {
err = ex.Message;
return string.Empty;
}
}
2、分析 public string Get() { string str = GetPage(KMADSLURL, strReq, out err);
Regex rgx = new Regex("table_det\\(\\n*\\s*\"([^\"]*)\",\\n*\\s*\"([^\"]*)\",\\n*\\s*\"([^\"]*)\",\\n*\\s*\"([^\"]*)\",\\n*\\s*\"([^\"]*)\",\\n*\\s*\"([^\"]*)\",\\n*\\s*\"([^\"]*)\",\\n*\\s*\"([^\"]*)\",\\n*\\s*\"([^\"]*)\",\\n*\\s*\"([^\"]*)\",\\n*\\s*\"([^\"]*)\"\\);", RegexOptions.Singleline); foreach (Match m in rgx.Matches(str)) {
Rec r = new Rec(); r.str1 = m.Groups[1].Value; r.Save(); } return null; }