Function posttofile(ByVal HttpUrl As String, ByVal poststr As String)
Dim Cookies As Net.CookieContainer = Nothing
Try
Dim code As String = "GB18030"
Dim Url As New System.Uri(HttpUrl & "?" & poststr)
Dim req As HttpWebRequest = WebRequest.Create(Url)
Dim SomeByte() As Byte = System.Text.Encoding.ASCII.GetBytes(poststr)
req.AllowAutoRedirect = True
req.Method = "POST"
req.ContentType = "application/x-www-form-urlencoded"
req.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Q312461; .NET CLR 1.0.3705)"
If Not (poststr Is Nothing) Then
req.ContentLength = SomeByte.Length
Else
req.ContentLength = 0
End If
If Not (Cookies Is Nothing) Then
req.CookieContainer = Cookies
Else
req.CookieContainer = New Net.CookieContainer
Cookies = req.CookieContainer
End If
req.GetRequestStream.Write(SomeByte, 0, SomeByte.Length)
Dim res As HttpWebResponse = req.GetResponse
Dim ReadStream As StreamReader = New StreamReader(res.GetResponseStream, System.Text.Encoding.GetEncoding(code))
Return ReadStream.ReadToEnd
Catch
End Try
End Function
Dim Cookies As Net.CookieContainer = Nothing
Try
Dim code As String = "GB18030"
Dim Url As New System.Uri(HttpUrl & "?" & poststr)
Dim req As HttpWebRequest = WebRequest.Create(Url)
Dim SomeByte() As Byte = System.Text.Encoding.ASCII.GetBytes(poststr)
req.AllowAutoRedirect = True
req.Method = "POST"
req.ContentType = "application/x-www-form-urlencoded"
req.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Q312461; .NET CLR 1.0.3705)"
If Not (poststr Is Nothing) Then
req.ContentLength = SomeByte.Length
Else
req.ContentLength = 0
End If
If Not (Cookies Is Nothing) Then
req.CookieContainer = Cookies
Else
req.CookieContainer = New Net.CookieContainer
Cookies = req.CookieContainer
End If
req.GetRequestStream.Write(SomeByte, 0, SomeByte.Length)
Dim res As HttpWebResponse = req.GetResponse
Dim ReadStream As StreamReader = New StreamReader(res.GetResponseStream, System.Text.Encoding.GetEncoding(code))
Return ReadStream.ReadToEnd
Catch
End Try
End Function
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货