我对Python有点陌生,我正在尝试理解如何从下面的代码中提取'title='
属性。我一直在尝试使用beautifulsoup,但老实说,任何将工作对我是好的。你知道吗
<a class="image-link" href="/new-jersey/communities/holiday-city-at-berkeley" title="Holiday City at Berkeley"><div class="lazyload pulse out exited" style="height:auto"><div class="placeholder"><svg class="svg-placeholder-component" height="100%" viewbox="0 0 400 225" width="100%"><use xlink:href="#lazyload-placeholder"></use></svg></div></div></a>
我试过all[0].find_all('a', "title")
和all[0].find_all("title")
,都返回了'[]'
。你知道吗
<a class="image-link" href="/new-jersey/communities/holiday-city-at-berkeley" title="Holiday City at Berkeley"><div class="lazyload pulse out exited" style="height:auto"><div class="placeholder"><svg class="svg-placeholder-component" height="100%" viewbox="0 0 400 225" width="100%"><use xlink:href="#lazyload-placeholder"></use></svg></div></div></a>
您可以使用CSS选择器提取所需的元素:
印刷品:
相关问题 更多 >
编程相关推荐