2017-01-09 32 views
0

我想在下面的鏈接使用VBA負載更多結果: http://www.flashscore.com/soccer/england/premier-league/results/如何使用VBA在網頁上加載更多結果?

頁面首先加載顯示我只是總成績的一半,但我想從加載頁面的所有數據。

我覺得我必須點擊「顯示更多匹配」鏈接,但我不知道該怎麼做。

任何人都可以幫助我的任何想法?

如果我有更多的遊戲加載和第一次點擊加載後更多的遊戲仍然是遊戲隱藏,我怎麼能看到所有的遊戲?

鏈接的源代碼是:

<a href="#" onclick="loadMoreGames(); return false;">Show more matches</a> 

下面你可以找到鏈接的屏幕拍:

Image link

+1

使用'的getElementsByTagName(「A」)'讓所有的頁面上的鏈接,然後在該檢查的innerText爲「顯示更多的比賽」循環的集合 - 調用'click'上匹配元素 –

+1

從我的一條建議:'直到InStr(ie.document.getElementById(「preload」)。getAttribute(「Style」),「display:none;」)<> 0:DoEvents:Loop'網站使用各種元素來通知加載狀態。 'IE.ReadyState'或'IE.Busy'通常會失敗。 –

回答

2

你可以看到函數名loadMoreGames()分配給onclick事件在錨節點<a href="#" onclick="loadMoreGames(); return false;">Show more matches</a>,所以你可能只是調用該函數而不是click()並循環等待,直到加載完成爲@RyszardJędraszyk評論:

Sub Test() 

    With CreateObject("InternetExplorer.Application") 
     .Visible = True 
     .Navigate "http://www.flashscore.com/soccer/england/premier-league/results/" 
     Do: DoEvents: Loop While .Busy Or .readyState <> 4 
     Do: DoEvents: Loop While .Document.readyState <> "complete" 
     .Document.parentWindow.execScript "loadMoreGames();" 
     Do: DoEvents: Loop While .Document.getElementById("preload").Style.display = "none" 
    End With 

End Sub 
相關問題