VB用Post方式登录学校网站能成功,但记笔记总是失败,急求大神帮忙看下!
vb用post方式登录学校网站,刚开始用的webbrowser模拟点击,可以登录,记笔记,但由于加载内容过多总假死,用了DoEvents也没用。只能换Post方式,因为要获取Cookie登录用的是Inet控件,
学校的登录网址如下:
http://www.hust-snde.com/center/left_hydl.jsp?url=www.hust-snde.com:80/sso/login_centerLogin.action
登录部分代码如下:
Dim myurl As String, send_data As String, my_head As String
myurl = "http://cas.hust-snde.com/whatyVerify"
send_data = "username=W201700958&password=" & MD5("321324198705175425") & "&service=http%3A%2F%2Fsns.hust-snde.com%2Flearning%2Fsso%2Flogin_webTrnLogin.action%3FssoUser.loginId%3DW201700958%26siteCode%3Dcode62"
my_head = "Content-Type: application/x-www-form-urlencoded" & vbCrLf
Inet1.Execute myurl, "POST", send_data, my_head
While Inet1.StillExecuting
DoEvents
Wend
Dim Buff() As Byte
Buff = Inet1.GetChunk(0, icByteArray)
If InStr(1, Utf8ToUnicode(Buff), "主机没有反应,连接尝试失败") Then
MsgBox "登录失败,对方网站没有响应!"
Else
’WebBrowser1.Navigate "http://sns.hust-snde.com/learning/entity/student/student_studentCourseList.action"
End If
以下部分是记笔记的代码:
myurl = "http://sns.hust-snde.com/learning/studyLog/studyLog_saveStudyLog.action"
send_data ="studyLog.isPub=0&studyLog.studyNote=%E7%AB%8B%E6%B3%95%E6%9D%83&studyLog.tagId=ff8080815bafb5c4015bc6b91d282781_03005760&studyLog.coursewareId=&studyLog.coursewareName="
my_head = "Content-Type: application/x-www-form-urlencoded" & vbCrLf
my_head = my_head & "Accept: application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*" & vbCrLf
my_head = my_head & "Referer: http://sns.hust-snde.com/learning/studyLog/studyLog_myStudylog.action" & vbCrLf
my_head = my_head & "Accept-Language: zh-CN" & vbCrLf
my_head = my_head & "Accept-Encoding: gzip, deflate" & vbCrLf
my_head = my_head & "Connection: Keep-Alive" & vbCrLf
Inet1.Execute myurl, "POST", send_data, my_head
While Inet1.StillExecuting
DoEvents
Wend
登录能成功,包括之前用webbrowser识别验证码然后再登录的,只是发帖一直没效果,用Winhttp带Cookie也一样,只有点击了webbrowser1窗口中“开始学习”按钮并等课件在webbrowser2中加载完再用代码Post方式记笔记的话就能成功(然后通过抓包工具抓取数据包再post"开始学习"按钮对应跳转的网页的话也没用)。
之前没怎么接触过Webbrowser、Inet控件、xmlhttp、Winhttp那种,希望大神帮忙,万分感谢!
学校的登录网址如下:
http://www.hust-snde.com/center/left_hydl.jsp?url=www.hust-snde.com:80/sso/login_centerLogin.action
登录部分代码如下:
Dim myurl As String, send_data As String, my_head As String
myurl = "http://cas.hust-snde.com/whatyVerify"
send_data = "username=W201700958&password=" & MD5("321324198705175425") & "&service=http%3A%2F%2Fsns.hust-snde.com%2Flearning%2Fsso%2Flogin_webTrnLogin.action%3FssoUser.loginId%3DW201700958%26siteCode%3Dcode62"
my_head = "Content-Type: application/x-www-form-urlencoded" & vbCrLf
Inet1.Execute myurl, "POST", send_data, my_head
While Inet1.StillExecuting
DoEvents
Wend
Dim Buff() As Byte
Buff = Inet1.GetChunk(0, icByteArray)
If InStr(1, Utf8ToUnicode(Buff), "主机没有反应,连接尝试失败") Then
MsgBox "登录失败,对方网站没有响应!"
Else
’WebBrowser1.Navigate "http://sns.hust-snde.com/learning/entity/student/student_studentCourseList.action"
End If
以下部分是记笔记的代码:
myurl = "http://sns.hust-snde.com/learning/studyLog/studyLog_saveStudyLog.action"
send_data ="studyLog.isPub=0&studyLog.studyNote=%E7%AB%8B%E6%B3%95%E6%9D%83&studyLog.tagId=ff8080815bafb5c4015bc6b91d282781_03005760&studyLog.coursewareId=&studyLog.coursewareName="
my_head = "Content-Type: application/x-www-form-urlencoded" & vbCrLf
my_head = my_head & "Accept: application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*" & vbCrLf
my_head = my_head & "Referer: http://sns.hust-snde.com/learning/studyLog/studyLog_myStudylog.action" & vbCrLf
my_head = my_head & "Accept-Language: zh-CN" & vbCrLf
my_head = my_head & "Accept-Encoding: gzip, deflate" & vbCrLf
my_head = my_head & "Connection: Keep-Alive" & vbCrLf
Inet1.Execute myurl, "POST", send_data, my_head
While Inet1.StillExecuting
DoEvents
Wend
登录能成功,包括之前用webbrowser识别验证码然后再登录的,只是发帖一直没效果,用Winhttp带Cookie也一样,只有点击了webbrowser1窗口中“开始学习”按钮并等课件在webbrowser2中加载完再用代码Post方式记笔记的话就能成功(然后通过抓包工具抓取数据包再post"开始学习"按钮对应跳转的网页的话也没用)。
之前没怎么接触过Webbrowser、Inet控件、xmlhttp、Winhttp那种,希望大神帮忙,万分感谢!
...全文
相关推荐
vb post 登录网站
以上就是关于VB使用POST方法登录网站的核心知识点。通过学习和实践,开发者可以掌握如何在VB中创建安全且有效的登录功能。
VB Post登陆网页Web QQ
**错误处理**:为了提供良好的用户体验,程序需要包含适当的错误处理机制,如网络连接失败、登录失败等情况的处理。8.
vb+asp登录程序
这使得用户在网站的其他页面间导航时仍保持登录状态。7. **错误处理**:良好的程序设计会包括错误处理机制,以应对可能出现的问题,如数据库连接失败、无效的用户名或密码等。8.
VB 登录126邮箱程序
126邮箱的登录过程通常涉及到向其服务器发送POST请求,包含用户名和密码等登录信息。POST数据需要编码,例如使用URL编码或Base64编码。2.
vb得到视频网站的点击率的方法(源码工程打包)
通过HTTP GET或POST请求,可以向视频网站发送请求并接收返回的HTML页面。1. **HTTP请求**:VB中的`MSXML2.XMLHTTP`对象可以用于发起HTTP请求。


网络编程
