擅长:python、mysql、java
<p>其他解决方案很好,但我更喜欢使用好的旧选择器</p>
<pre><code>from bs4 import BeautifulSoup as bs
import requests as req
page = req.get('https://www.lyrics.com/album/1447935')
soup = bs(page.content, 'html.parser')
links = soup.select('table.tdata a[href]')
print(links)
</code></pre>
<p>这将打印</p>
<pre><code>[<a href="/lyric/15183453/Make+You+Feel+My+Love">Make You Feel My Love</a>, <a href="/lyric/15183454/Painting+Pictures">Painting Pictures</a>]
</code></pre>
<hr/>
<p>如果您不熟悉选择器,这将获取具有类<code>tdata</code>的<code>table</code>元素,然后收集<code>a</code>元素上的所有<code>href</code>属性</p>