WebClient wc = new WebClient();
string str = wc.DownloadString("http:/xxxxxx/regedit/login_check.asp");
String str1 = "正则表达式";
MatchCollection mc = Regex.Matches(str, str1);
//循环获取数据,操作
for (int i = 0; i < mc.Count; i++)
{
Match m = mc[i];
}
ASCIIEncoding encoding = new ASCIIEncoding();
//参数
byte[] data = encoding.GetBytes("username=ddd&password=123456");
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://xxxxxx/regedit/login.asp");
request.Method = "Post";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = data.Length;
request.KeepAlive = true;
//发送数据
Stream newStream = request.GetRequestStream();
newStream.Write(data, 0, data.Length);
newStream.Close();
//以下俩句不可缺少
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
//(int)response.StatusCode 返回请求结果状态码
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.Default);
string content = reader.ReadToEnd();
String str1 = "正则表达式";
MatchCollection mc = Regex.Matches(content, str1);
//循环获取数据,操作
for (int i = 0; i < mc.Count; i++)
{
Match m = mc[i];
}