winfrom C Post提交 帶參數 ,返回值
阿新 • • 發佈:2019-03-11
mes encoding led utili rdate cap method nco comment
分享一下我老師大神的人工智能教程吧。零基礎!通俗易懂!風趣幽默!還帶黃段子!希望你也加入到我們人工智能的隊伍中來!http://www.captainbed.net
public void PostMoths()
{
string strURL = "http://www.cqjg.gov.cn/newwww/c7/clwz.asp";
System.Net.HttpWebRequest request;
request = (System.Net.HttpWebRequest)WebRequest.Create(strURL);
//Post請求方式
request.Method = "POST";
//內容類型
request.ContentType = "application/x-www-form-urlencoded";
//參數經過URL編碼
string paraUrlCoded = System.Web.HttpUtility.UrlEncode("LicenseTxt");
paraUrlCoded += "=" + System.Web.HttpUtility.UrlEncode(txtCarId .Text.Trim());
paraUrlCoded +="& " + System.Web.HttpUtility.UrlEncode("VIN");
paraUrlCoded += "=" + System.Web.HttpUtility.UrlEncode(txtCarNumber.Text.Trim());
byte[] payload;
//將URL編碼後的字符串轉化為字節
payload = System.Text.Encoding.UTF8.GetBytes(paraUrlCoded);
//設置請求的ContentLength
request.ContentLength = payload.Length;
//獲得請求流
Stream writer = request.GetRequestStream();
//將請求參數寫入流
writer.Write(payload, 0, payload.Length);
//關閉請求流
writer.Close();
System.Net.HttpWebResponse response;
//獲得響應流
response = (System.Net.HttpWebResponse)request.GetResponse();
System.IO.Stream s;
s = response.GetResponseStream();
string StrDate = "";
string strValue = "";
StreamReader Reader = new StreamReader(s,Encoding.Default);
while ((StrDate= Reader.ReadLine())!=null)
{
strValue += StrDate+"\r\n";
}
// txtInfo.Text = strValue;
txtInfo.Text= FindContent(strValue);
//XmlTextReader Reader = new XmlTextReader(s);
//Reader.MoveToContent();
//string strValue = Reader.ReadInnerXml();
//strValue = strValue.Replace("<", "<");
//strValue = strValue.Replace(">", ">");
//MessageBox.Show(strValue);
//Reader.Close();
}
再分享一下我老師大神的人工智能教程吧。零基礎!通俗易懂!風趣幽默!還帶黃段子!希望你也加入到我們人工智能的隊伍中來!http://www.captainbed.net
winfrom C Post提交 帶參數 ,返回值