Python:从 BeautifulSoup 中查找元素

Python: find elements from BeautifulSoup

使用 BeautifulSoup 我无法提取我需要的所有元素:

例如,来自这部分:

[<div class="item-info-container">
 <picture class="logo-branding">
 <a data-markup="listado::logo-agencia" href="/en/pro/remax-yes/" title="RE/MAX Yes">
 <img alt="RE/MAX Yes" src="https://st3.idealista.pt/4b/f5/86/remax-yes.gif"/>
 </a>
 </picture>
 <a aria-level="2" class="item-link" href="/en/imovel/31306786/" role="heading" title="T3 flat in rua das Janelas Verdes 128, tornejando para a Tv. Das Atafonas 1, 1, Prazeres, Estrela">T3 flat in rua das Janelas Verdes 128, tornejando para a Tv. Das Atafonas 1, 1, Prazeres, Estrela</a>
 <div class="price-row ">
 <span class="item-price h2-simulated">769,000<span class="txt-big">€</span></span>
 <span class="item-parking">Garage included</span>
 <span class="pricedown">
 <span class="pricedown_price">
 785,000 €
 </span>
 <span class="pricedown_icon icon-pricedown">2%</span>
 </span>
 </div>
 <span class="item-detail">T3 <small></small></span>
 <span class="item-detail">147 <small>m²</small></span>
 <span class="item-detail">2nd floor <small> with lift</small></span>
 <div class="item-description description">
 <p class="ellipsis ">
 T3 full of charm, comfort and tranquility
 Excellent T3 with 147 m2, inserted in a private condominium with garden, with 2 parking spaces...
 </p>
 <span class="listing-tags">
 Luxury
 </span>
 </div>
 <div class="item-toolbar">
 <span class="icon-phone item-not-clickable-phone">215552845</span>
 <a class="icon-phone phone-btn item-clickable-phone" href="tel:+351 215552845" target="_blank">
 <span>Call</span>
 </a>
 <button class="icon-chat email-btn action-email fake-anchor"><span>Contact</span></button>
 <button class=" favorite-btn action-fav fake-anchor" data-role="add" data-text-add="Save" data-text-remove="Favourite" title="Save">
 <i class="icon-heart" role="image"></i>
 <span>Save</span>
 </button>
 <button class="icon-delete trash-btn action-discard fake-anchor" data-role="add" data-text-remove="Discard" rel="nofollow" title="Discard">
 </button>
 </div>

我已经能够导入 PRICE、TIPOLOGY 和 CONTACT

price=all[0].find("span",{"class":"item-price h2-simulated"}).text
tipology=all[0].find("span",{"class":"item-detail"}).text
contact=all[0].find("span",{"class":"icon-phone item-not-clickable-phone"}).text

我仍然无法提取: LINK 和标题:

 <a aria-level="2" class="item-link" href="/en/imovel/31306786/" role="heading" title="T3 flat in rua das Janelas Verdes 128, tornejando para a Tv. Das Atafonas 1, 1, Prazeres, Estrela">T3 flat in rua das Janelas Verdes 128, tornejando para a Tv. Das Atafonas 1, 1, Prazeres, Estrela</a>

HOUSE AREA 和 HOUSE FLOOR 因为它们等于拓扑结构:

     <span class="item-detail">147 <small>m²</small></span>
     <span class="item-detail">2nd floor <small> with lift</small></span>

谁能帮我解决这个问题

您可以尝试如下操作:

link=all[0].find("a",class_="item-link")['href']

title=link=all[0].find("a",class_="item-link").get_text()