关于Webbrowser自动填表单递交问题,请帮忙看下。
网站地址:http://www.godaddy.com/bulk-domain-search.aspx?isc=iapdom799t&ci=8991我在VB里加了Webbrowser控件,进入这个页面后,通过VB向textarea里填写好了,但怎么样都递交不了。代码如下:
Web.Document.getElementById("bulkSearchArea").innerText = "abcefge" & Chr(13) & "d"
Web.Document.getElementById("bulkSearchBtn").click
Web是窗体中的Webbrowser控件。bulkSearchBtn是递交链接的ID。
这个页面在VB中怎么样都无法递交,但直接用IE打开,填写好表单后单击GO链接可以正常递交。这几天都为这个问题搞晕了头,请大家来帮个忙,看问题出在哪? VB Internet Explorer --------------------编程问答-------------------- 我试了一下,Web.Document.getElementById("bulkSearchBtn").click,运行这句后页面搜索产生了变了化。噢,我加了一段代码,限制出现新窗口出现。
Dim WithEvents Web_V1 As SHDocVwCtl.WebBrowser_V1
Private Sub Form_Load()
Set Web_V1 = WebBrowser1.Object
End Sub
Private Sub Web_V1_NewWindow(ByVal URL As String, ByVal Flags As Long, ByVal TargetFrameName As String, PostData As Variant, ByVal Headers As String, Processed As Boolean)
Processed = True
WebBrowser1.Navigate URL
End Sub
--------------------编程问答-------------------- 楼上的,你这代码也没解决我那问题啦。帮忙 再研究一下吧。 --------------------编程问答--------------------
WebBrowser1.Document.GetElementById("bulkSearchBtn").InvokeMember("click")--------------------编程问答--------------------
--------------------编程问答-------------------- 木有权限修改,重发一次:
Private Sub CommandButton3_Click()
On Error Resume Next
cz = InputBox("比如说baidu", "向textarea里填写什么?", "baidu")
Set oDoc = CreateObject("htmlfile")
With CreateObject("WinHttp.WinHttpRequest.5.1")
.Open "GET", "http://www.godaddy.com/bulk-domain-search.aspx?isc=iapdom799t&ci=8991", False
.send
MyCookie = GetCookie(.getAllResponseHeaders)
.Open "POST", "http://www.godaddy.com/domains/actions/dodomainbulksearch.aspx?source=%2fbulk-domain-search.aspx&isc=iapdom799t", False
.SetRequestHeader "Referer", "http://www.godaddy.com/bulk-domain-search.aspx?isc=iapdom799t&ci=8991"
.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
.SetRequestHeader "Connection", "Keep-Alive"
.SetRequestHeader "Cookie", MyCookie
.send "domainNames=" & cz & "&dotTypes=&extrnl=1&bulk=1&redirectTo=customize"
tt = .responsetext
oDoc.body.innerHTML = .responsetext
MsgBox oDoc.forms("易做图BulkSearch").all.tags("table")(0).innerText
End With
End Sub
Private Sub CommandButton3_Click()
On Error Resume Next
cz = InputBox("比如说baidu", "向textarea里填写什么?", "baidu")
Set oDoc = CreateObject("htmlfile")
With CreateObject("WinHttp.WinHttpRequest.5.1")
.Open "GET", "http://www.godaddy.com/bulk-domain-search.aspx?isc=iapdom799t&ci=8991", False
.send
MyCookie = GetCookie(.getAllResponseHeaders)
.Open "POST", "http://www.godaddy.com/domains/actions/dodomainbulksearch.aspx?source=%2fbulk-domain-search.aspx&isc=iapdom799t", False
.SetRequestHeader "Referer", "http://www.godaddy.com/bulk-domain-search.aspx?isc=iapdom799t&ci=8991"
.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
.SetRequestHeader "Connection", "Keep-Alive"
.SetRequestHeader "Cookie", MyCookie
.send "domainNames=" & cz & "&dotTypes=&extrnl=1&bulk=1&redirectTo=customize"
tt = .responsetext
oDoc.body.innerHTML = .responsetext
MsgBox oDoc.forms("易做图BulkSearch").all.tags("table")(0).innerText
End With
End Sub
Private Function GetCookie(Str$) 'GetCookie(.getAllResponseHeaders)
Dim cookie$, a&, b&, c$, d&, e&, f$
a = InStr(Str, "Set-Cookie: ")
If a = 0 Then
GetCookie = ""
Else
b = InStr(a, Str, ";"): c = Mid(Str, a + 12, b - a - 11)
cookie = c
Do
d = InStr(b, Str, "Set-Cookie: ")
If d = 0 Then Exit Do
e = InStr(d, Str, ";"): f = Mid(Str, d + 12, e - d - 11)
b = e
cookie = cookie & f
Loop
GetCookie = cookie
End If
End Function
补充:VB , 网络编程