Garfield(猫仔|别忘了结帖,同志) 大侠:您好!谢谢您的解答!现在我还是调试不通,有几个问题,请教: '以下代码是我参考“http://expert.csdn.net/Expert/FAQ/FAQ_Index.asp?id=177681”写的,不知错在哪里 Private Sub Form_Load()With Inet1 .URL = "http://expert.csdn.net/" .UserName = "****" '请换上一个会员名 .Password = "******" '请换上该会员的密码 End With Inet1.Execute , "POST" End SubPrivate Sub Inet1_StateChanged(ByVal State As Integer) Select Case State Case 12 'Text1.Text = "HTTP:" + Inet1.GetHeader("HTTP") + vbCrLf _ + "Expires:" + Inet1.GetHeader("Expires") + vbCrLf _ + "Date:" + Inet1.GetHeader("Date") + vbCrLf _ + "Server:" + Inet1.GetHeader("Server") + vbCrLf _ + "Set-Cookie:" + Inet1.GetHeader("Set-Cookie") + vbCrLf _ + "Content-type:" + Inet1.GetHeader("Content-type") + vbCrLf _ + "Content-Length:" + Inet1.GetHeader("Content-Length") + vbCrLf _ + "Last-Modified:" + Inet1.GetHeader("Last-Modified") Case Else End Select End Sub '上面的代码运行的结果如下:
HTTP: Expires: Date:Wed, 03 Sep 2003 08:01:25 GMT Server: Microsoft -IIS / 5# Set-Cookie: Content-type:text/html Content-Length:3647 Last -Modified: 请问:(1)为什么上面的HTTP,Expires及Set-Cookie参数是空的呢? (2)怎样才能用inet控件(或者是winsock,webbrowser控件)打开“我的专家分”那一页?()
1) 登陆的地址错误,应该是 http://expert.csdn.net/member/logon.asp 2) 用户名密码弄错地方,那个是inet使用代理服务器时的验证密码改为: Private Sub Form_Load() Inet1.Execute "http://expert.csdn.net/member/logon.asp", "POST", "name=用户&pass=密码" end sub
Garfield(猫仔|别忘了结帖,同志) 大侠:您好! 我上面还有一个问题,帮解答一下,好吗? 其他大侠也请帮帮忙则个。 谢谢先!---那个问题就是: 我用下面的代码,先登录,再看http://expert.csdn.net/Expert/member/MyExpertPoint.asp的源代码,与我手工登录再在IE里打开该页面的源代码,有很大的不同: Private Sub Form_Load() Inet1.Execute "http://expert.csdn.net/member/logon.asp", "POST", "name=名字&pass=密码"Do While Inet1.StillExecuting DoEvents Loop Text1.Text = Inet1.OpenURL("http://expert.csdn.net/Expert/member/MyExpertPoint.asp")End Sub'End SubPrivate Sub Inet1_StateChanged(ByVal State As Integer) Select Case State Case 12 Text1.Text = "HTTP:" + Inet1.GetHeader("HTTP") + vbCrLf _ + "Expires:" + Inet1.GetHeader("Expires") + vbCrLf _ + "Date:" + Inet1.GetHeader("Date") + vbCrLf _ + "Server:" + Inet1.GetHeader("Server") + vbCrLf _ + "Set-Cookie:" + Inet1.GetHeader("Set-Cookie") + vbCrLf _ + "Content-type:" + Inet1.GetHeader("Content-type") + vbCrLf _ + "Content-Length:" + Inet1.GetHeader("Content-Length") + vbCrLf _ + "Last-Modified:" + Inet1.GetHeader("Last-Modified") MsgBox "1234253425" Case Else End Select End Sub 这是为什么?请教请教!
你直接再用 Execute url,"GET","" , Cookies Cookies = 第一次登陆后用 inet1.getheader("Set-Cookie")
应该是 Execute url,"GET","" , "Set-Cookie: " & Cookies
还是不通。我的代码如下:Option Explicit Dim URL As String Dim Cookies As StringPrivate Sub Form_Load() Inet1.Execute "http://expert.csdn.net/member/logon.asp", "POST", "name=姓名&pass=密码" URL = "http://expert.csdn.net/Expert/member/MyExpertPoint.asp" End SubPrivate Sub Inet1_StateChanged(ByVal State As Integer) Select Case State Case 12 Cookies = Inet1.GetHeader("Set-Cookie") Case Else End Select Inet2.Execute URL, "GET", "", "Set-Cookie: " & CookiesEnd Sub Private Sub Inet2_StateChanged(ByVal State As Integer) On Error Resume Next Dim stemp As String Dim PageCode As String Select Case State Case 12 stemp = Inet2.GetChunk(1024) Do While stemp <> "" PageCode = PageCode + stemp stemp = Inet2.GetChunk(1024) Loop text1.text= PageCode End Select End Sub在“Inet2.Execute URL, "GET", "", "Set-Cookie: " & Cookies”那一句报错。继续请教!
呵呵。。搞糊涂了其实很简单,inet会保存cookies。。不需要像winsock那样代码直接改为: Option Explicit Dim URL As String Dim Cookies As StringPrivate Sub Form_Load() Dim stemp As String, pagecode As StringInet1.Execute "http://expert.csdn.net/member/logon.asp?name=用户&pass=密码&from=http://expert.csdn.net/expert", "POST"
Do Until Inet1.StillExecuting = False DoEvents Loop URL = "http://expert.csdn.net/Expert/member/MyExpertPoint.asp" Inet1.Execute URL, "GET" ', "", "Cookie: " & Cookies & vbCrLf Do Until Inet1.StillExecuting = False DoEvents Loop stemp = Inet1.GetChunk(1024) Do While stemp <> "" pagecode = pagecode + stemp stemp = Inet1.GetChunk(1024) Loop Text1 = pagecodeEnd Sub
注:我的代码如下: Option Explicit Dim URL As String Dim Cookies As String Private Sub Form_Load()Inet1.Execute "http://expert.csdn.net/member/logon.asp?name=用户&pass=密码&from=http://expert.csdn.net/expert", "POST" End SubPrivate Sub Inet1_StateChanged(ByVal State As Integer) Select Case State Case 12 Cookies = Inet1.GetHeader("Set-Cookie") Case Else URL = "http://expert.csdn.net/Expert/member/MyExpertPoint.asp" Inet2.Execute URL, "GET", "", "Cookie: " & Cookies & vbCrLf End Select End SubPrivate Sub Inet2_StateChanged(ByVal State As Integer) Dim stemp As String, pagecode As String stemp = Inet2.GetChunk(1024) Do While stemp <> "" pagecode = pagecode + stemp stemp = Inet2.GetChunk(1024) Loop Text1.Text = pagecode End Sub
'以下代码是我参考“http://expert.csdn.net/Expert/FAQ/FAQ_Index.asp?id=177681”写的,不知错在哪里
Private Sub Form_Load()With Inet1
.URL = "http://expert.csdn.net/"
.UserName = "****" '请换上一个会员名
.Password = "******" '请换上该会员的密码
End With
Inet1.Execute , "POST"
End SubPrivate Sub Inet1_StateChanged(ByVal State As Integer)
Select Case State
Case 12
'Text1.Text = "HTTP:" + Inet1.GetHeader("HTTP") + vbCrLf _
+ "Expires:" + Inet1.GetHeader("Expires") + vbCrLf _
+ "Date:" + Inet1.GetHeader("Date") + vbCrLf _
+ "Server:" + Inet1.GetHeader("Server") + vbCrLf _
+ "Set-Cookie:" + Inet1.GetHeader("Set-Cookie") + vbCrLf _
+ "Content-type:" + Inet1.GetHeader("Content-type") + vbCrLf _
+ "Content-Length:" + Inet1.GetHeader("Content-Length") + vbCrLf _
+ "Last-Modified:" + Inet1.GetHeader("Last-Modified")
Case Else
End Select
End Sub '上面的代码运行的结果如下:
HTTP:
Expires:
Date:Wed, 03 Sep 2003 08:01:25 GMT
Server: Microsoft -IIS / 5#
Set-Cookie:
Content-type:text/html
Content-Length:3647
Last -Modified:
请问:(1)为什么上面的HTTP,Expires及Set-Cookie参数是空的呢?
(2)怎样才能用inet控件(或者是winsock,webbrowser控件)打开“我的专家分”那一页?()
2) 用户名密码弄错地方,那个是inet使用代理服务器时的验证密码改为:
Private Sub Form_Load()
Inet1.Execute "http://expert.csdn.net/member/logon.asp", "POST", "name=用户&pass=密码"
end sub
(2)另外,您的那个登录页面"http://expert.csdn.net/member/logon.asp",是怎么找到的?谢谢解答!
Private Sub Form_Load()
Inet1.Execute "http://expert.csdn.net/member/logon.asp", "POST", "name=名字&pass=密码"Do While Inet1.StillExecuting
DoEvents
Loop
Text1.Text = Inet1.OpenURL("http://expert.csdn.net/Expert/member/MyExpertPoint.asp")End Sub'End SubPrivate Sub Inet1_StateChanged(ByVal State As Integer)
Select Case State
Case 12
Text1.Text = "HTTP:" + Inet1.GetHeader("HTTP") + vbCrLf _
+ "Expires:" + Inet1.GetHeader("Expires") + vbCrLf _
+ "Date:" + Inet1.GetHeader("Date") + vbCrLf _
+ "Server:" + Inet1.GetHeader("Server") + vbCrLf _
+ "Set-Cookie:" + Inet1.GetHeader("Set-Cookie") + vbCrLf _
+ "Content-type:" + Inet1.GetHeader("Content-type") + vbCrLf _
+ "Content-Length:" + Inet1.GetHeader("Content-Length") + vbCrLf _
+ "Last-Modified:" + Inet1.GetHeader("Last-Modified")
MsgBox "1234253425"
Case Else
End Select
End Sub
这是为什么?请教请教!
2) 你看登陆的html页面,post form的action属性就是了。
我上面还有一个问题,帮解答一下,好吗?
其他大侠也请帮帮忙则个。
谢谢先!---那个问题就是:
我用下面的代码,先登录,再看http://expert.csdn.net/Expert/member/MyExpertPoint.asp的源代码,与我手工登录再在IE里打开该页面的源代码,有很大的不同:
Private Sub Form_Load()
Inet1.Execute "http://expert.csdn.net/member/logon.asp", "POST", "name=名字&pass=密码"Do While Inet1.StillExecuting
DoEvents
Loop
Text1.Text = Inet1.OpenURL("http://expert.csdn.net/Expert/member/MyExpertPoint.asp")End Sub'End SubPrivate Sub Inet1_StateChanged(ByVal State As Integer)
Select Case State
Case 12
Text1.Text = "HTTP:" + Inet1.GetHeader("HTTP") + vbCrLf _
+ "Expires:" + Inet1.GetHeader("Expires") + vbCrLf _
+ "Date:" + Inet1.GetHeader("Date") + vbCrLf _
+ "Server:" + Inet1.GetHeader("Server") + vbCrLf _
+ "Set-Cookie:" + Inet1.GetHeader("Set-Cookie") + vbCrLf _
+ "Content-type:" + Inet1.GetHeader("Content-type") + vbCrLf _
+ "Content-Length:" + Inet1.GetHeader("Content-Length") + vbCrLf _
+ "Last-Modified:" + Inet1.GetHeader("Last-Modified")
MsgBox "1234253425"
Case Else
End Select
End Sub
这是为什么?请教请教!
Cookies = 第一次登陆后用 inet1.getheader("Set-Cookie")
Dim URL As String
Dim Cookies As StringPrivate Sub Form_Load()
Inet1.Execute "http://expert.csdn.net/member/logon.asp", "POST", "name=姓名&pass=密码"
URL = "http://expert.csdn.net/Expert/member/MyExpertPoint.asp"
End SubPrivate Sub Inet1_StateChanged(ByVal State As Integer)
Select Case State
Case 12
Cookies = Inet1.GetHeader("Set-Cookie")
Case Else
End Select
Inet2.Execute URL, "GET", "", "Set-Cookie: " & CookiesEnd Sub
Private Sub Inet2_StateChanged(ByVal State As Integer)
On Error Resume Next
Dim stemp As String
Dim PageCode As String
Select Case State
Case 12
stemp = Inet2.GetChunk(1024)
Do While stemp <> ""
PageCode = PageCode + stemp
stemp = Inet2.GetChunk(1024)
Loop
text1.text= PageCode
End Select
End Sub在“Inet2.Execute URL, "GET", "", "Set-Cookie: " & Cookies”那一句报错。继续请教!
Option Explicit
Dim URL As String
Dim Cookies As StringPrivate Sub Form_Load()
Dim stemp As String, pagecode As StringInet1.Execute "http://expert.csdn.net/member/logon.asp?name=用户&pass=密码&from=http://expert.csdn.net/expert", "POST"
Do Until Inet1.StillExecuting = False
DoEvents
Loop
URL = "http://expert.csdn.net/Expert/member/MyExpertPoint.asp"
Inet1.Execute URL, "GET" ', "", "Cookie: " & Cookies & vbCrLf
Do Until Inet1.StillExecuting = False
DoEvents
Loop
stemp = Inet1.GetChunk(1024)
Do While stemp <> ""
pagecode = pagecode + stemp
stemp = Inet1.GetChunk(1024)
Loop
Text1 = pagecodeEnd Sub
报:
实时错误:'35756'
不能完成请求
还是定位在Inet1.Execute URL, "GET" , "", "Cookie: " & Cookies & vbCrLf上.
(注:Garfield(猫仔|别忘了结帖,同志) 大侠,您地代码在GET后面多了一个'号吧?)继续请教!
Option Explicit
Dim URL As String
Dim Cookies As String
Private Sub Form_Load()Inet1.Execute "http://expert.csdn.net/member/logon.asp?name=用户&pass=密码&from=http://expert.csdn.net/expert", "POST"
End SubPrivate Sub Inet1_StateChanged(ByVal State As Integer)
Select Case State
Case 12
Cookies = Inet1.GetHeader("Set-Cookie")
Case Else
URL = "http://expert.csdn.net/Expert/member/MyExpertPoint.asp"
Inet2.Execute URL, "GET", "", "Cookie: " & Cookies & vbCrLf
End Select
End SubPrivate Sub Inet2_StateChanged(ByVal State As Integer)
Dim stemp As String, pagecode As String
stemp = Inet2.GetChunk(1024)
Do While stemp <> ""
pagecode = pagecode + stemp
stemp = Inet2.GetChunk(1024)
Loop
Text1.Text = pagecode
End Sub
如果两个,不知道两个inet与服务器的asp会话是否一致。你怎么运行不了??
我完全可以通过。
谢谢Garfield(猫仔|别忘了结帖,同志) 大侠!
原来那个'号是您注释掉的,我还以为是您“笔误”呢。sorry!(' 是我把后面的都注释掉,没用的代码。)请教:为什么下面的代码要inet1控件“不忙”时doevents?
Do Until Inet1.StillExecuting = False
DoEvents
Loop
inet1是异步的,下面的这行代码一开始时不管执行完成与否,都要继续它下面的代码行,对吗?
Inet1.Execute "http://expert.csdn.net/member/logon.asp?name=用户&pass=密码&from=http://expert.csdn.net/expert", "POST"请教下面代码的奥秘。
Do Until Inet1.StillExecuting = False
DoEvents
Loop
如果你inet1.execute后面直接再跟一个inet.execute会说“仍在进行上一个处理”
所以我用 do/loop 来阻塞主线程。
1,可以保证已经登陆。
2,避免inet的错误。
doevents (响应事件)
直到inet的仍在处理=否 (until inet.stillexecuting = false)
结构上事这样,只是程序语言不是这样写。
看来你最需要搞懂的是英文单词 "Until" 的意思。
给分了!