There is a place to extract the content of the web page. I checked some information on the Internet. I checked some in MSDN. I just made a backup. It is convenient for future use. I haven't made it in a hurry. I haven't finished it. I can understand it. Yes, 嘿嘿
The default GET seems to be relatively simple, the only thing to pay attention to is the conversion of the character set, otherwise there is a problem in Chinese display.
Dim WebReq As Net.HttpWebRequest Dim strUrl As String strUrl = Trim (txtAddress.Text) & "?" & _ "StrDistrictSmall =" & System.Web.HttpUtility.UrlEncode (txtPara1.Text, System.Text.Encoding.GetEncoding ( " GB2312 ")) & _" & strDistrict = "& System.Web.HttpUtility.UrlEncode (Txtpara2.Text, System.Text.Encoding.GetEncoding (" GB2312 ")) WebReq = CType (WebRequest.Create (strUrl), HttpWebRequest) WebReq . HEADERS ("Accept-language") = "zh-cn" 'Req.Headers ("accept-language") = "zh-cn"' WebReq.Headers.Add ("Accept-encoding", "UTF-8" )
DIM Webres as net.httpwebresponse = WebReq.getResponse () Dim Readr as new ostreamreader (WebRES.GETRESPONSESTREAM, System.Text.Encoding.Getencoding ("GB2312"))
TextBox1.text = Readr.ReadToend Msgbox ("Complete")
POST is slightly more complicated, and the personal error is the WebRequest's Method property is not set (there is not set in MSDN)
Dim WebReq As Net.HttpWebRequest Dim strUrl As String strUrl = "strDistrictSmall =" & System.Web.HttpUtility.UrlEncode (txtPara1.Text, System.Text.Encoding.GetEncoding ( "GB2312")) & _ "& strDistrict =" & System .Web.HttpUtility.UrlEncode (Txtpara2.Text, System.Text.Encoding.GetEncoding ( "GB2312")) WebReq = CType (WebRequest.Create (Trim (txtAddress.Text)), HttpWebRequest) 'WebReq.Headers ( "Accept- ") =" Zh-cn "'Req.Headers (" accept-language ") =" zh-cn "' WebReq.Headers.Add (" Accept-encoding "," UTF-8 ") DIM Postbyte as Byte ) = Encoding.ASCII.GetBytes (strUrl) WebReq.ContentType = "application / x-www-form-urlencoded" WebReq.ContentLength = Postbyte.Length WebReq.Method = "POST" Dim NewStream As IO.Stream = WebReq.GetRequestStream ( NEWSTREAM.WRITE (Postbyte, 0, Postbyte.Length) newstream.close () DIM Webres as net.httpwebresponse = WebReq.getResponse Dim Readr as new ostreamre ADER (WebRES.Text.Encoding.Getencoding ("GB2312"))
TextBox1.text = readr.readToend Readr.close () MSGBox ("Complete")