WebBrowser2.Navigate "http://diamonds.com/Main/SearchResult.aspx?CaratSizeFrom=0&CaratSizeTo=100&shape=round", False While WebBrowser2.Busy DoEvents Wend WebBrowser2.Navigate "javascript:__doPostBack('ctl00$cphMainContent$gvSearchResult','Page$10')" 返回同样错误
WebBrowser2.Navigate "http://diamonds.com/Main/SearchResult.aspx?CaratSizeFrom=0&CaratSizeTo=100&shape=round", False While WebBrowser2.Busy DoEvents Wend WebBrowser2.Navigate "javascript:__doPostBack('ctl00$cphMainContent$gvSearchResult','Page$10')" 返回同样错误
出错时因为那个页面上没有 Page$10 这个东西, 所以,先翻到有Page$10的页面,再调用Page$10Private Sub Form_Load() WebBrowser1.Navigate2 " http://diamonds.com/Main/SearchResult.aspx?CaratSizeFrom=0&CaratSizeTo=100&shape=round" End SubPrivate Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant) Static lStep As Long
If lStep = 2 Then Exit Sub
Dim oWindow As HTMLWindow2 Set oWindow = pDisp.Document.parentWindow
Select Case lStep Case 0 oWindow.execScript "javascript:__doPostBack('ctl00$cphMainContent$gvSearchResult','Page$6')" Case 1 oWindow.execScript "javascript:__doPostBack('ctl00$cphMainContent$gvSearchResult','Page$10')" End Select
lStep = lStep + 1 End Sub
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant) Dim link As Object
Set link = Me.WebBrowser1.Document.getElementsByTagName("A")(89) If link.innerText = "..." Or link.innerText = "10" Then link.Click Else MsgBox Me.WebBrowser1.Document.body.innerHTML End If End Sub
Option ExplicitDim clsWeb1 As New clsWebMasterPrivate Sub Form_Load() WebBrowser1.Navigate "http://diamonds.com/Main/SearchResult.aspx?CaratSizeFrom=0&CaratSizeTo=100&shape=round" End SubPrivate Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant) Static isOk As Boolean If isOk Then MsgBox WebBrowser1.Document.body.INNERHTML Exit Sub End If If clsWeb1.IsTagExist(WebBrowser1, "A", eHREF, "Page$10", , False) Then clsWeb1.ClickTag WebBrowser1, "A", eHREF, "Page$10", , False isOk = True Else clsWeb1.ClickTag WebBrowser1, "A", eINNERHTML, "..." End If End Sub 需要引用一个dll,下载地址:http://commonprogrames.googlecode.com/files/WebMasterDemo.rar
We're sorry, but an Unexpected Error has occurred.
Click here to go back.
WebBrowser1.Document.All("__EVENTARGUMENT").Value = "Page$10"
WebBrowser1.Document.Forms("aspnetForm").submit
返回同样的错误
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
While WebBrowser2.Busy
DoEvents
Wend
WebBrowser2.Navigate "javascript:__doPostBack('ctl00$cphMainContent$gvSearchResult','Page$10')"
返回同样错误
While WebBrowser2.Busy
DoEvents
Wend
WebBrowser2.Navigate "javascript:__doPostBack('ctl00$cphMainContent$gvSearchResult','Page$10')"
返回同样错误
WebBrowser1.Navigate2 " http://diamonds.com/Main/SearchResult.aspx?CaratSizeFrom=0&CaratSizeTo=100&shape=round"
End SubPrivate Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
Static lStep As Long
If lStep = 2 Then Exit Sub
Dim oWindow As HTMLWindow2
Set oWindow = pDisp.Document.parentWindow
Select Case lStep
Case 0
oWindow.execScript "javascript:__doPostBack('ctl00$cphMainContent$gvSearchResult','Page$6')"
Case 1
oWindow.execScript "javascript:__doPostBack('ctl00$cphMainContent$gvSearchResult','Page$10')"
End Select
lStep = lStep + 1
End Sub
Dim link As Object
Set link = Me.WebBrowser1.Document.getElementsByTagName("A")(89)
If link.innerText = "..." Or link.innerText = "10" Then
link.Click
Else
MsgBox Me.WebBrowser1.Document.body.innerHTML
End If
End Sub
WebBrowser1.Navigate "http://diamonds.com/Main/SearchResult.aspx?CaratSizeFrom=0&CaratSizeTo=100&shape=round"
End SubPrivate Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
Static isOk As Boolean
If isOk Then
MsgBox WebBrowser1.Document.body.INNERHTML
Exit Sub
End If If clsWeb1.IsTagExist(WebBrowser1, "A", eHREF, "Page$10", , False) Then
clsWeb1.ClickTag WebBrowser1, "A", eHREF, "Page$10", , False
isOk = True
Else
clsWeb1.ClickTag WebBrowser1, "A", eINNERHTML, "..."
End If
End Sub
需要引用一个dll,下载地址:http://commonprogrames.googlecode.com/files/WebMasterDemo.rar