Python抓取隐藏数据

时间:2020-09-29 21:46:13

标签: python html selenium web-scraping beautifulsoup

我需要从对象上抓取文本,但首先必须将鼠标悬停在该对象上。原始代码如下:

<app-tooltip-widget _nghost-tmf-c12="">
    <div _ngcontent-tmf-c12="" triggers="" class="">
        <img alt="Info icon" class="img-fluid shipments-info-icon" src="info.png">
    </div>
</app-tooltip-widget>

当我将鼠标悬停在上面时:

<app-tooltip-widget _nghost-sqv-c21="">
    <div _ngcontent-sqv-c21="" triggers="" class="" aria-describedby="tooltip-21">
        <img alt="Info icon" class="img-fluid shipments-info-icon" src="info.png">
        </div>
    </app-tooltip-widget>
出现“ aria- describeby =“ tooltip-21”” 我需要里面的废料信息 我正在尝试:

driver = webdriver.Chrome()

driver.get('example.com')
driver.maximize_window()

men_menu = WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, '//div[@_ngcontent-sqv-c21=""]')))
ActionChains(driver).move_to_element(men_menu).perform()

data = driver.find_element_by_xpath('//*[@aria-describedby="tooltip-23"]').text
print(data)

0 个答案:

没有答案
相关问题