level 1
weijiasihai
楼主
Imports System.Net
Imports System.IO
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim requ As HttpWebRequest
Dim resp As HttpWebResponse
Dim cc As New CookieContainer
Dim url As String
url = "http://www.163.com"
Try
requ = DirectCast(WebRequest.Create(url), HttpWebRequest)
With requ
.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0b; Windows NT 5.1)"
.Method = "GET"
.CookieContainer = cc
.Timeout = 10000
End With
resp = DirectCast(requ.GetResponse(), HttpWebResponse)
MsgBox(resp.Cookies("DomAuthSessId"))
Dim out As Stream
out = resp.GetResponseStream
Dim sr As StreamReader
sr = New StreamReader(out, System.Text.Encoding.GetEncoding(60051))
Dim html As String
html = sr.ReadToEnd.ToString
MsgBox(html)
Catch ex As Exception
End Try
End Sub
End Class
2014年01月14日 14点01分
1
Imports System.IO
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim requ As HttpWebRequest
Dim resp As HttpWebResponse
Dim cc As New CookieContainer
Dim url As String
url = "http://www.163.com"
Try
requ = DirectCast(WebRequest.Create(url), HttpWebRequest)
With requ
.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0b; Windows NT 5.1)"
.Method = "GET"
.CookieContainer = cc
.Timeout = 10000
End With
resp = DirectCast(requ.GetResponse(), HttpWebResponse)
MsgBox(resp.Cookies("DomAuthSessId"))
Dim out As Stream
out = resp.GetResponseStream
Dim sr As StreamReader
sr = New StreamReader(out, System.Text.Encoding.GetEncoding(60051))
Dim html As String
html = sr.ReadToEnd.ToString
MsgBox(html)
Catch ex As Exception
End Try
End Sub
End Class