加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

利用vb向网页提交表单数据的实现代码

发布时间:2020-12-16 23:21:38 所属栏目:大数据 来源:网络整理
导读:首先,先建立一个工程,加一个窗体form1,上面添加一个textbox控件text1,和两个按钮 分别为command1和command2, 然后实现按下command1按钮就向网页提交text1的内容 先打开菜单里的,工程-〉引用-〉选中microsoft xml,必须先这样,因为下面要用到msxml对象

首先,先建立一个工程,加一个窗体form1,上面添加一个textbox控件text1,和两个按钮
分别为command1和command2,
然后实现按下command1按钮就向网页提交text1的内容
先打开菜单里的,工程-〉引用-〉选中microsoft xml,必须先这样,因为下面要用到msxml对象
button1的实现代码如下:
Private Sub Command1_Click()
On Error Resume Next
Dim oXmlHttp As New MSXML.XMLHTTPRequest
Dim sPostString As String,sRespText As String

sPostString = "ID = " + Text1.Text '需要提交的数据"
oXmlHttp.open "POST","http://127.0.0.1",False

'一定要加上下面的这一句,说明提交类型的
oXmlHttp.setRequestHeader "content-type","application/x-www-form-urlencoded "
"
oXmlHttp.send (sPostString)
sRespText = oXmlHttp.responseText '得到处理后response回来的数据
'sRespText为返回的结果,可以根据结果进行处理,具体处理请根据需要编写
oXmlHttp = Nothing
End Sub

Private Sub Command1_Click()
Inet1.Execute "http://localhost/test/recevie.asp","post","info=" + Text1.Text,"Content-Type: application/x-www-form-urlencoded "
Do While Inet1.StillExecuting
DoEvents
Loop
Text2.Text = Inet1.GetChunk(1024,icString)

MsgBox ("yes")

End Sub

vb提取验证码

Option Explicit

Private Sub Command1_Click()
WebBrowser1.Navigate "
http://www.m5home.com/blog/login.asp"
End SubPrivate Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object,URL As Variant) If URL <> "" Then Dim Img As Object,CR As Object Set Img = WebBrowser1.Document.getElementById("vcodeImg") '根据验证码的ID取得这个对象 Set CR = WebBrowser1.Document.body.createControlRange() '设置选区 CR.Add Img '添加验证码图片对象到选区 CR.execCommand ("Copy") '复制 Set Picture1.Picture = Clipboard.GetData() '粘贴过去 End IfEnd Sub

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读