我在Python中使用beautifulsoup,要得到所有鏈接:如何從DOM中的頁面獲取所有鏈接?
links = soup.select('.cover > .card-click-target')
print(links);
但它給了我一個元素和字符串值的數組。
我的HTML代碼:
<div class="cover">
<div class="cover-image-container">
<div class="cover-outer-align">
<div class="cover-inner-align">
<img alt="Kate Mobile Lite" class="cover-image" data-cover-large="" data-cover-small="" src="" aria-hidden="true">
</div>
</div>
</div>
<a class="card-click-target" href="/s/kate_new_6" aria-label=" Kate Mobile Lite ">
<span class="movies preordered-overlay-container id-preordered-overlay-container" style="display:none">
<span class="preordered-label">Предзаказ</span>
</span>
<span class="preview-overlay-container"> </span>
</a>
</div>
<div class="cover">
<div class="cover-image-container">
<div class="cover-outer-align">
<div class="cover-inner-align">
<img alt="Kate Mobile Lite" class="cover-image" data-cover-large="" data-cover-small="" src="" aria-hidden="true">
</div>
</div>
</div>
<a class="card-click-target" href="/s/kate_new_6" aria-label=" Kate Mobile Lite ">
<span class="movies preordered-overlay-container id-preordered-overlay-container" style="display:none">
<span class="preordered-label">Предзаказ</span>
</span>
<span class="preview-overlay-container">
</span>
</a>
</div>
不看真的很難幫助頁面的實際來源,但如果你正在尋找鏈接(這是'a't ags),你應該使用'find_all('a')'。 – Dekel
再次請看問題,我作了更改 – MisterPi
我沒有看到任何更改 – Dekel