我刚刚开始在excel VBA中使用硒库。
我正在尝试在Instagram上将关注者打印到Excel,但是显示我关注的人的窗口不会显示联系人,除非他们掉线。
我尝试过:
driver.ExecuteScript "window.scrollTo(0, document.body.scrollHeight);"
但是没有用。
我已经尝试过.ScrollIntoView
,但是也没有用。
我的代码:
Private Sub CommandButton1_Click()
Dim baglan As New Selenium.WebDriver, el As WebElements
baglan.AddArgument ("--incognito")
baglan.Start "chrome"
baglan.Get ("instagram.com/")
baglan.FindElementByXPath("/html/body/div[1]/section/main/article/div[2]/div[1]/div/form/div[2]/div/label/input").SendKeys "username"
baglan.FindElementByXPath("/html/body/div[1]/section/main/article/div[2]/div[1]/div/form/div[3]/div/label/input").SendKeys "password"
baglan.FindElementByXPath("/html/body/div[1]/section/main/article/div[2]/div[1]/div/form/div[4]/button/div").Click
baglan.Wait 10000
baglan.FindElementByXPath("/html/body/div[4]/div/div/div[3]/button[2]").Click
baglan.FindElementByXPath("/html/body/div[1]/section/nav/div[2]/div/div/div[3]/div/div[3]/a").Click
baglan.FindElementByXPath("/html/body/div[1]/section/main/div/header/section/ul/li[3]/a").Click
a = baglan.FindElementByXPath("/html/body/div[1]/section/main/div/header/section/ul/li[3]/a/span").Text
baglan.ExecuteScript "window.scrollTo(0, document.body.scrollHeight);"
Set el = baglan.FindElementByClass("PZuss").FindElementsByTag("li")
For i = 1 To a
baglan.Wait 1000
'Cells(i, 1) = baglan.FindElementByXPath("/html/body/div[4]/div/div[2]/ul/div/li[" & i & "]/div/div[2]/div[1]/div/div/a").Text
Next i
End Sub