Public Function MyPost() As Boolean
'Dim list As List(Of GetIP) = JsonConvert.DeserializeObject(Of List(Of GetIP))(jo("data").ToString())
'Dim ip As String = list(0).ip
'Dim port As Integer = list(0).port
Dim HttpUrl As New System.Uri(Url)
Try
httpReq = CType(WebRequest.Create(HttpUrl), HttpWebRequest)
httpReq.Timeout = Timeout '服务器超时时间
httpReq.CookieContainer = MyCookies
httpReq.Method = "POST"
If ref <> "" Then
httpReq.Referer = ref
ref = ""
End If
httpReq.Accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, */*"
Dim bytesData() As Byte
httpReq.ContentType = "application/x-www-form-urlencoded; charset=UTF-8"
bytesData = System.Text.Encoding.ASCII.GetBytes(PostData)
httpReq.Headers.Add("Accept-Language", "zh-cn")
httpReq.Headers.Add("Pragma", "no-cache")
httpReq.Headers.Add("Cache-Control", "no-cache")
httpReq.Headers.Add("X-Requested-With", "XMLHttpRequest")
httpReq.Headers.Add("Upgrade-Insecure-Requests", "1")
httpReq.UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64;) (KHTML,like Gecko) Chrome/73.0.3683.86 safari/537.36"
httpReq.KeepAlive = True
httpReq.ServicePoint.Expect100Continue = False
httpReq.ContentLength = bytesData.Length
Dim postStream As Stream = httpReq.GetRequestStream()
postStream.Write(bytesData, 0, bytesData.Length)
postStream.Close()
httpRes = CType(httpReq.GetResponse(), HttpWebResponse)
sr = New StreamReader(httpRes.GetResponseStream, System.Text.Encoding.GetEncoding(charset))
Html = sr.ReadToEnd()
Return True
Catch WebExcp As WebException
ErrMsg = WebExcp.Message.ToString()
Catch ex As Exception
ErrMsg = ex.Message.ToString()
Finally
Try
If Not sr Is Nothing Then sr.Close()
Catch WebExcp As WebException
Catch ex As Exception
End Try
Try
If Not httpReq Is Nothing Then httpReq.GetRequestStream().Close()
Catch WebExcp As WebException
Catch ex As Exception
End Try
Try
If Not httpRes Is Nothing Then httpRes.GetResponseStream().Close()
Catch WebExcp As WebException
Catch ex As Exception
End Try
End Try
End Function