【发布时间】:2021-07-05 10:29:04
【问题描述】:
我有这样的路径
<div class="accordion-group">
...
<span class="country-container u-text-ellipsis">
此容器包含有关国家/地区及其相对价值的信息。
<a itemprop="url" class="country-name country-name--link" href="/top-websites/Switzerland"><Switzerland"</a>
我想从这个国家中脱颖而出。 我还有其他与这个国家有关的信息,我想提取。 路径是
<div class="acccordion-group">
...
<span class="traffic-share-valueNumber js-countValue">3.95%</span>
容器包含多个信息,路径与上述相同。示例:
我试过这个:
driver.find_element_by_xpath('//span[@class="traffic-share-valueNumber js-countValue"]').get_attribute('textContent')
它只适用于一个值。
您能解释一下如何获取有关国家/地区及其百分比的所有信息吗?如果您需要,很乐意提供更多信息。 我想要这个预期的输出(df):
Country Percentage
Italy 87.81%
Switzerland 3.95%
Germany 2.75%
... ...
【问题讨论】:
-
你能分享一个网页链接吗?
标签: python selenium-webdriver web-scraping selenium-chromedriver