|
Sub 网页抓取selenium()
Dim Service As SeleniumBasic.ChromeDriverService
Dim Options As SeleniumBasic.ChromeOptions
Set WD = New SeleniumBasic.IWebDriver
Set Service = New SeleniumBasic.ChromeDriverService
With Service
.CreateDefaultService driverPath:="D:\安装包\Chrome-Selenium\Chrome-bin"
.HideCommandPromptWindow = True
End With
Set Options = New SeleniumBasic.ChromeOptions
With Options
.BinaryLocation = "D:\安装包\Chrome-Selenium\Chrome-bin\chrome.exe"
End With
WD.New_ChromeDriver Service:=Service, Options:=Options
WD.url = "http://www.bizwar.cn/main/login"
WD.FindElementByName("name").SendKeys "9@99"
WD.FindElementByName("password").SendKeys
WD.FindElementByName("commit").Click
WD.url = "http://www.bizwar.cn/games/decision?gameid=328772&mode=old&part=last_pay&periodid=3190913&teamid=561206&type=raw"
WD.SwitchTo.Alert.Accept
Dim rowc, tr, td, columnC As Integer
rowc = 1
For Each tr In WD.FindElementByXPath("/html/body/div/div[4]/div/div/div[2]/div[1]/form/table/tbody/tr/td[2]/table").FindElementsByTagName("tr")
columnC = 1
For Each td In tr.FindElementsByTagName("td")
Sheet3.Cells(rowc, columnC).Value = td.Text
columnC = columnC + 1
Next td
rowc = rowc + 1
Next tr
End Sub
请问一下“For Each tr In WD.FindElementByXPath("/html/body/div/div[4]/div/div/div[2]/div[1]/form/table/tbody/tr/td[2]/table").FindElementsByTagName("tr")”这段代码在执行时提示变量使用了一个不支持的自动化变量,请问这个怎么解决。 |
|