我想利用Webbrowser获取http://www.cma.gov.cn/(中国气象局)的天气
可是不能不知道为什么模拟点提交的时候直本不能提交只能手工点提交才能成功.
但其它网可以实现用程序模拟提交,这我百思不得其解,请各位指点。
Private Sub Command1_Click()
Dim doc As IHTMLDocument2
Set doc = WebBrowser1.Document
If Form1.Caption = "http://www.cma.gov.cn/tqyb/weatherdetail/54511.html" Then
Dim Inputs As IHTMLElementCollection
Set Inputs = doc.All.tags("INPUT")
Dim Element As IHTMLElement
Set Element = Inputs.Item(2, 0)
Dim InputElement As IHTMLInputElement
Set InputElement = Element
InputElement.Value = Text1.Text
doc.Forms.Item(3, 0).submit '模拟点"提交"按钮
End If
End Sub
Private Sub Form_Load()
WebBrowser1.Navigate2 "http://www.cma.gov.cn/tqyb/weatherdetail/54511.html"
End Sub
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
Form1.Caption = URL
End Sub
红色字体处模拟点"提交"
源程序
[此贴子已经被作者于2006-12-18 14:08:06编辑过]