如何使用硒在div之外获取文本?

问题描述 投票:0回答:1

screenshot

<div class="amlocator-store-information" style="" xpath="1"> 
 <div class="amlocator-title" style="">The Better Health Store</div>
                    2420 E-Stadium Ann Arbor MI 48104<br><br>
(613) 975-6613
 <div style="" class="amasty_distance" id="amasty_distance_1">Distance:                            
   <span class="amasty_distance_number"></span>
                        </div>
                    </div>

我正在将selenium与python结合使用,并尝试从DOM中获取地址,但我不能,我用过

store_block_list  = '//div[@class="amlocator-store-information"]'
store_block_list = '//div[@class="amlocator-title"]'

捕获元素,但无法获取地址,因为您可以看到地址位于// div元素之外请注意,这是一个元素列表,然后我使用for循环在元素列表周围循环

python selenium xpath css-selectors webdriverwait
1个回答
0
投票

要提取地址,即2420 E-Stadium Ann Arbor MI 48104

© www.soinside.com 2019 - 2024. All rights reserved.