【发布时间】:2019-06-13 08:07:15
【问题描述】:
如何在this page 上获取此“h2”标题的所有“href”属性?
<h2 class="entry-title">
<a href="http://www.allitebooks.com/deep-learning-with-python-2/" rel="bookmark">Deep Learning with Python</a>
</h2>
我试过的没有得到href,是:
title = driver.find_elements_by_class_name('entry-title')
title[0].get_attribute('href')
这没有得到“a”标签的链接。如果我在“a”标签上查找所有元素,它将返回页面上的每个href(这不是我想要的)。我想只返回上面的标题,但能够获取它们的 url“href”属性。
【问题讨论】: