使用chrome vba selenium的动态工具提示值提取

oyt4ldly  于 2023-08-01  发布在  Go
关注(0)|答案(1)|浏览(99)

我面临的问题,在动态工具提示值使用VBA chrome selenium ,现在的问题,在其他数据提取,因为一切顺利,但面临的问题,在动态工具提示值。我的代码如下所示。

d.Get "https://norway.dealroom.co/companies/nortech_1"
Sleep 200
'On Error Resume Next
'------------------------------------------
'For i = 1 To 65

'Set my_data = d.FindElementsByClass("to_hasTooltip")
'For Each Item In my_data
'href11 = Item.Attribute("href")
'
'Dim news As String
'news = href11 & "{}" & "{}" & url & "}{"
'news1 = MyClean(news)
'
'news1 = Replace(news1, "{}", vbTab)
'news1 = Replace(news1, "}{", vbLf)
'
'Fileout.write news1
'href11 = ""
'Next
'd.FindElementByCss("a.to_hasTooltip:nth-child(7)").Click
'd.FindElementByCss("a.to_hasTooltip:nth-child(5)").Click
'Next
'------------------------------------------
d.FindElementByXPath("/html/body/div[2]/div/div[2]/div[3]/div[1]/main/div/div/section/div[2]/div/div[1]/div[2]/div[1]/div[1]/span/span").Click

ab = d.FindElementByClass("tooltip-wraper--open").text
MsgBox (ab)

字符串

ijxebb2r

ijxebb2r1#

参考下面的代码,工作正常。使用action类,在所需元素上执行鼠标悬停,然后获取工具提示文本。#输出:由Louis Geoffroy-Terryn于2023年6月29日检查

import the webdriver
import time

from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
driver.maximize_window()
driver.implicitly_wait(10)
# get method to launch the URL
driver.get("https://norway.dealroom.co/companies/nortech_1")
# to scroll with Javascript executor

driver.execute_script('return document.title')
time.sleep(10)
hoverable = driver.find_element(By.XPATH, "//span[@class='icon-font icon-checkmark verified-icon "
                                          "verified-icon--verified']")
ActionChains(driver).move_to_element(hoverable).perform()
ab = driver.find_element(By.XPATH,"//body/div[@class='drop-down-portal']/div[@role='dialog']/div["
                                  "@class='balloon-dialog__content balloon-dialog__content--tooltip']/span[1]").text
print(ab)

字符串

相关问题